[英]Comparing two columns in different tables based on condition
我有两个表,如图所示
表格1:
| ldt | swpn | nomenclature | planned | combined |
表2:
| lmt | name | combination |
我必须实现:
检查“组合”列中是否存在“组合”列中的值。
如果存在,则输出相应的| lmt | name | combination |
| lmt | name | combination |
使用INNER JOIN,它用于从JOIN的LEFT和RIGHT的两个表中获取结果
SELECT t2.lmt, t2.name, t2.combination
FROM
t1
INNER JOIN t2 ON t1.combined=t2.combination
SELECT Table2.lmt, Table2.name, Table2.combination FROM Table1, Table2 WHERE Table2.combination=Table1.combined
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.