我有一个看起来像这样的插入(使用 MySQL)
INSERT INTO user_actions(action_id,user_id,action_type,record_id,on_table) VALUES
(
action_id,
'1',
'1',
'32',
'1'
)
ON DUPLICATE KEY UPDATE
user_id=user_id AND
action_type = action_type AND
record_id = record_id AND
on_table = on_table
并且action_id
是AUTO_INCREMENT
仅当某些值不同时才插入表中的目标 si。
我的错误是什么??
其次,我可以用选择做一个 IF、ELSE 吗?喜欢
var_count = count
(
SELECT action_id FROM user_actions
WHERE
action_id = 'value' AND
user_id 'value' AND
action_type 'value'
record_id 'value' AND
on_table 'value' AND
)
IF var_count = 0
INSERT INTO user_actions(action_id,user_id,action_type,record_id,on_table) VALUES
(
action_id,
'1',
'1',
'32',
'1'
)
ELSE
... echo error
END IF