仅当表中不存在此命令时,我才想向我的 MySql 表中添加一行:
INSERT INTO client.viewcount (clientid, userid)
SELECT * FROM (SELECT '1111111', '222') AS tmp
WHERE NOT EXISTS (
SELECT clientid,userid FROM client.viewcount WHERE clientid = '1111111' AND userid = '222'
) LIMIT 1;
仅当表中不存在时才有效并插入。我有另一张桌子的问题
Users
id userid viewcount
1 123456 45
2 987741 62
3 741369 20
我希望能够增加viewcount
用户的数量。类似的东西:如果我添加
(clientid,userid) => (a432543,123456)
If it's not exist in the table => Insert and increase the viewcount to 46.
我可以在一个推荐中实施它吗?