I have 2 tables :table1 and table2.When using this query,
SELECT *
FROM table1 a
WHERE a.name IN (SELECT name FROM table2 )
The result is 20.
When I want update data based on this query
UPDATE table1 SET number='1'
FROM table1 a
WHERE a.name IN (SELECT name FROM table2)
The result is all the number will be set to 1 instead of only 20.The default number is 0.
Try this
UPDATE table1 t1 SET number=1
JOIN table2 t2 ON t1.name = t2.name
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.