0

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
4

2 回答 2

0

我认为replace into如果您在两列上添加唯一键,您可以使用

REPLACE INTO table (id, title, description) 
VALUES(1, 'hello', 'world')    
于 2012-04-05T12:44:38.700 回答
0
INSERT INTO TABLE (ID, TITLE, DESCRIPTION) VALUES (1, 'hello', 'world')
WHERE (SELECT COUNT(ID) FROM TABLE WHERE TITLE='hello' AND DESCRIPTION='world') = 0
于 2012-04-05T12:45:28.697 回答