我有這兩個表:SQL查詢新手問題
表1
Itemid Username Rate Opinion
0944947 pooh_sweety_70 3.2 Negative
0468569 pooh_sweety_70 Positive
0411008 liamvdheuvel 2.1 Negative
0468569 liamvdheuvel 3.4 Negative
1375666 liamvdheuvel 1.5 Negative
0903747 liamvdheuvel 5.5 Negative
0412142 rzajac 4.8 Negative
2267998 rzajac 9.2 Positive
1074638 rzajac 7.4 Positive
1182345 rzajac 6.1 Negative
0468569 rzajac 3.3 Negative
1856010 michaelsmith01 9.9 Positive
1486217 michaelsmith01 Positive
1300854 michaelsmith01 2.4 Negative
2267998 pooh_sweety_70 8.4 Positive
2911666 aswilliams40 8.7 Positive
1074638 aswilliams40 9.4 Positive
0468569 aswilliams40 8.2 Positive
表2
Username Password
aswilliams40 pantsftw
liamvdheuvel qwascoolzuiop
michaelsmith01 ilovejessica
rzajac toocoolforscool
pooh_sweety_70 legendarymythic
而且我想找到其密碼包含單詞「酷」的用戶某個地方,並且該用戶還必須始終對項目留下否定意見,如果他們對該項目進行了評級。未分級的項目不重要。
我試圖把查詢在一起,但它並沒有真正的工作:/
SELECT Username FROM Table1, Table2
WHERE Table1.Username = Table2.Username AND
Table2.Password LIKE '%cool%' AND
Table1.Rate IS NOT NULL AND
Table1.Opinion = 'Negative';
所以基本上我唯一想要的輸出是「liamvdheuvel」
做什麼你的意思是不起作用? –
'WHERE Table2.Username = Table2.Username AND'?將一個表更改爲Table1 – c4pricorn
它給出了以下錯誤:字段列表中的列'用戶名'不明確 –