I would like to insert a row only if two values(or more) of the query is different:
INSERT INTO table (id, title, description)
VALUES(1, 'hello', 'world')
ONLY IF title AND description DOESN't ALREADY EXISTS
I would like to insert a row only if two values(or more) of the query is different:
INSERT INTO table (id, title, description)
VALUES(1, 'hello', 'world')
ONLY IF title AND description DOESN't ALREADY EXISTS
我认为replace into
如果您在两列上添加唯一键,您可以使用
REPLACE INTO table (id, title, description)
VALUES(1, 'hello', 'world')
INSERT INTO TABLE (ID, TITLE, DESCRIPTION) VALUES (1, 'hello', 'world')
WHERE (SELECT COUNT(ID) FROM TABLE WHERE TITLE='hello' AND DESCRIPTION='world') = 0