nemakuphp Posted December 21, 2009 Report Share Posted December 21, 2009 (edited) Pagaidām kverijs ir šāds: SELECT a.*, COUNT(c.lauks1) AS count FROM `tabula1` a LEFT JOIN `tabula2` c ON c.lauks2=a.lauks3 GROUP BY a.lauks3, c.lauks2 ORDER BY a.lauks5 ASC Viss notiek, taču ir viena problēma. Kā norādīt, lai viņš pie COUNT ņem vērā tikai tos laukus, no visiem lauks1, kur vērtība ir 1? Varat slēgt, laikam iznāca, taču nezinu vai tā ir pareizi. SELECT a.*, COUNT(c.lauks1) AS count FROM `tabula1` a LEFT JOIN `tabula2` c ON c.lauks2=a.lauks3 AND c.lauks1=1 GROUP BY a.lauks3, c.lauks2 ORDER BY a.lauks5 ASC Ja nav pareizi, palabojiet Edited December 21, 2009 by nemakuphp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.