Is there a SQL command for inserting data into a row where the id = the table id, and if it doesnt exists then insert into a new row?
Something like: ('INSERT INTO USERS IF EXISTS WHERE userID=ID')
Is there a SQL command for inserting data into a row where the id = the table id, and if it doesnt exists then insert into a new row?
Something like: ('INSERT INTO USERS IF EXISTS WHERE userID=ID')
I understood your question like this
INSERT INTO table1(value1, value2)
SELECT value1, value2 FROM table2where table2.userID = Id
You can write something simple like this:
IF (SELECT COUNT(t.ID) FROM t WHERE t.ID=@id)=1
UPDATE
ELSE
INSERT