-1
這是查詢的輸出: SQL查詢GROUP BY ID過濾器?
SELECT * FROM ((SELECT privatemsgs.id, privatemsgs.useradn, privatemsgs.useraid, privatemsgs.title, privatemsgs.created, privatemsgs.timee, privatemsgs.isread, u.photo AS creatorphoto, privatemsgs.relatedto FROM privatemsgs LEFT JOIN users AS u ON(privatemsgs.useraid = u.id) WHERE userbid='$myid' AND relatedto=0 and bdel=1) UNION (SELECT privatemsgs.id, privatemsgs.useradn, privatemsgs.useraid, privatemsgs.title, privatemsgs.created, privatemsgs.timee, privatemsgs.isread, u.photo AS creatorphoto, rel.relatedto FROM privatemsgs AS rel JOIN privatemsgs ON(rel.relatedto = privatemsgs.id) LEFT JOIN users AS u ON(rel.useraid = u.id) WHERE rel.userbid='$myid' )) privatemsgs GROUP BY id ORDER BY timee DESC
我有雙號 「2」。第一個是「isread = 0」,第二個是「isread = 1」。
當我補充說:「通過ID組」,我有(2號線)
但我需要輸出到顯示isread = 1(如3號線)
如何解決呢?
請提供查詢 – 2013-03-19 13:12:49
提示:'MAX(isread)'和'GROUP BY id' – 2013-03-19 13:12:50
發佈查詢本身plz:D我們不知道您使用的是什麼查詢:) – imclickingmaniac 2013-03-19 13:12:59