我遇到了我的sql查询问题。如果存在或不存在,我需要插入一个需要首先检查的数据。如果数据存在,则sql查询必须返回它,否则插入并返回它。我已经谷歌它,但结果是不太适合我的问题。我已经读过这个。SQL检查是否存在行,如果没有插入并返回它
Check if a row exists, otherwise insert How to 'insert if not exists' in MySQL?
这里是一个查询,”我在想。
INSERT INTO @tablename(@field, @conditional_field, @field, @conditional_field)
VALUES(
"value of field"
(SQL QUERY THAT CHECK IF THERE IS AN EXISTING DATA, IF NOT INSERT THE DATA and RETURN IT, IF YES return it),
"value of feild",
(SQL QUERY THAT CHECK IF THERE IS AN EXISTING DATA, IF NOT INSERT THE DATA and RETURN IT, IF YES return it)
);
请注意,条件字段是必填字段,因此它不能为NULL。
定义“回归它”的意思 – 2014-10-20 11:25:18