| Start |
|---|
MERGE to make Target match Source Note: The |
| MySQL: counting users by name Suppose we want to know how many users have the same name. Let us create table Now, we just discovered a new user named Joe and would like to take him into account. To achieve that, we need to determine whether there is an existing row with his name, and if so, update it to increment count; on the other hand, if there is no existing row, we should create it. MySQL uses the following syntax : insert … on duplicate key update … (opens new window). In this case: |
| PostgreSQL: counting users by name Suppose we want to know how many users have the same name. Let us create table Now, we just discovered a new user named Joe and would like to take him into account. To achieve that, we need to determine whether there is an existing row with his name, and if so, update it to increment count; on the other hand, if there is no existing row, we should create it. PostgreSQL uses the following syntax : insert … on conflict … do update … (opens new window). In this case: |
Read Article
https://develop.horje.com/learn/1434/reference