亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

How does mysql determine if the data does not exist and then insert it?
怪我咯
怪我咯 2017-07-04 13:43:40
0
4
1102

When inserting data, can we combine the following requirements into one sql statement?

1, determine whether the data exists;

2, there is no insertion;

3, then query the id field value of the data

怪我咯
怪我咯

走同樣的路,發(fā)現(xiàn)不同的人生

reply all(4)
淡淡煙草味

Probably not possible, you have to do two queries separately, one query and one insert. Unless you call a stored procedure. The stored procedure should be able to achieve your needs

阿神

Use insert if not exists

INSERT INTO table(field1, field2, fieldn) SELECT 'field1', 'field2', 'fieldn' FROM DUAL WHERE NOT EXISTS(SELECT field FROM table WHERE field = ?)
劉奇

MySQL, please use the powerful REPLACE INTO

世界只因有你

Mysql can use REPLACE INTO, but it must have a unique index as a condition, but I have not used this, I feel it is more reliable to do it step by step

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template