【发布时间】:2021-08-13 11:46:09
【问题描述】:
我有 2 张桌子:
表 1:
task cnt
1 4
2 5
3 6
表 2:
task cnt2
1 7
2 5
3 6
4 3
我想为表 2 添加一列,这样如果表 1 中的任务的 cnt 与表 2 中的任务的 cnt2 相同。如果不匹配,则标记为“不匹配”
想要的结果:
task cnt2 if_matched
1 7 'no match'
2 5 'yes'
3 6 'yes'
4 3 'no match'
我从如下查询开始,选择具有匹配值的任务
select task from table1 where table1.cnt = table2.cnt2
但是 where 部分出现错误。
【问题讨论】:
-
此时,与任何有关 MySQL 的基本介绍性书籍或教程在一起 5 分钟都会很有用