2015-08-27 9 views
0

我有兩個表不同的表兩列:如圖</p> <p>表1的比較以基於條件

| ldt | swpn | nomenclature | planned | combined  | 

表2:

| lmt | name | combination | 

我必須實現:

  1. 檢查列「c組合「列中存在」組合「列。

  2. 如果存在打印出相應的| lmt | name | combination |

+1

什麼問題? – Gaur93

+0

我現在編輯了這個問題。對於那個很抱歉! – akrish

+0

'select * from table2 where combination in(select from table1)' – splash58

回答

0

使用一個內連接,其用於從在左表和RIGHT得到的結果JOIN

SELECT t2.lmt, t2.name, t2.combination 
FROM 
    t1 
    INNER JOIN t2 ON t1.combined=t2.combination 
0
SELECT Table2.lmt, Table2.name, Table2.combination FROM Table1, Table2 WHERE Table2.combination=Table1.combined 
+1

請編輯更多信息。只有代碼和「試試這個」的答案是[灰心](http://meta.stackexchange.com/questions/196187/is-try-this-bad-practice),因爲它們不包含可搜索的內容,也不解釋爲什麼有人應該「嘗試這個」。我們在這裏努力成爲知識的資源。 –