Skip to content

MERGE table, do nothing when matched

I have a table DOMAINS in 2 different schemas with columns ID, NAME,CODE,DESCRIPTION. For any NAME exist in new schema, it should use existing ID without any merge; for those new NAME records, it should insert with ID from old schema. How can i intepret the portion of do nothing in above query? Answer For you…

Adding a new column with data

Below is my table: Now I want to add a new column called ‘Gender’ with values M,M,M,F in 4 rows respectively. I first added a new column using: Now I understand I can add data one by one by using: But how do I add all 4 data at once? Answer You don’t, unless there is some other piece of

MySQL script triggers Error #1241

I have the script below, which is supposed to get a price for an array of ID’s that has been provided. But it needs to get 1 price per ID, and the tricky part is, that I want to have the ability to have scheduled price updates. This mean that it needs to take the price that is <= UTC_TIMESTAMP

Avoid duplicates in postgreSQL

I’m using postgreSQL version 10.3 and I have a table like this: I want to make numerous INSERT and make sure there are no duplicates. So I thought about using INSERT INTO … ON CONFLICT DO NOTHING;. The idea is to insert the record only if the values on the columns first | second | third | fourth |…

LINQ Room id where user exists

I have two tables: ChatRoom Id (int) ChatUser (where i insert the users to the chat room, 1 row per user) RoomId (int) // Id from table ChatRoom UserId (int) I want to loop out all rooms where im in i do like this. But how do get the room id where the second user with the variable userId2 exists?

Mysql counting join table OneToMany

Task: id | title | description | ——————————————————————— 1 | Task1 | Descr1 | 2 | Task2 | Descr1 | 3 | Task2 | Descr1 | 4 |…