我为一个表做了两个查询。
SELECT url FROM links WHERE post = '0' AND keywords = 'key';
然后
UPDATE links SET post='1' WHERE keywords = 'key';
但是因为很多线程我得到了重复。 如何将这两个请求合二为一? 感谢
答案 0 :(得分:2)
答案 1 :(得分:1)
试试这个
UPDATE links SET post='1' WHERE keywords = 'key' AND post = '0';
OR
UPDATE links SET post='1' WHERE url in
(SELECT url FROM links WHERE post = '0' AND keywords = 'key');
答案 2 :(得分:1)
这可能适合你。
UPDATE links SET post='1' WHERE keywords in
(SELECT keywords FROM links WHERE post = '0' AND keywords = 'key');