1
說得這個問題簡單,我用的是follwoing命令:PHP SQL查詢使用陣列
SELECT DISTINCT a.*, b.shortmessage
FROM `users` a, `rating` b
WHERE a.userid IN (333333, 101010)
AND b.myuserid IN (333333, 101010)
AND b.userid LIKE '000000'
它返回:
id other_columns shortmessage
3 Guy1 message from guy1
9 Guy2 message from guy1
3 Guy1 message from guy2
9 Guy2 message from guy2
注意,我可以使用GROUP BY id
,它會顯示2行如預期的那樣,但表2的消息在guy2上將會出錯。
我想要什麼:
id other_columns shortmessage
3 Guy1 message from guy1
9 Guy2 message from guy2
您如何定義哪個'shortmessage'應該顯示爲特定* Guy * /'id'? –