Microsoft sql 2008
以下三个表通过b = b和d = d相关联 我想查询3个表并使用表1中的声明集column1 = a更新表2 column3 = d中的值,并在表3中声明set column2 = f。一旦满足条件,更新表2 column3,其值为table3 column3
SELECT videos.id, count(*) video_comments
FROM videos LEFT JOIN comments
ON comments.comments_video_id = videos.id
GROUP BY videos.id
ORDER BY video_comments DESC
答案 0 :(得分:0)
UPDATE table2 t2
INNER JOIN table1 t1 ON t1.column2=t2.column2
INNER JOIN table3 t3 ON t3.column3=t2.column3
SET t2.column3=t3.column3
WHERE t1.column1='a'
AND t2.column2='f'
喜欢这个吗?