繁体   English   中英

根据条件比较不同表中的两列

[英]Comparing two columns in different tables based on condition

我有两个表,如图所示

表格1:

| ldt    | swpn   | nomenclature | planned | combined     |

表2:

| lmt | name | combination |

我必须实现:

  1. 检查“组合”列中是否存在“组合”列中的值。

  2. 如果存在,则输出相应的| 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM