2009年3月24日星期二

Re: [fw-db] Queries with LEFT JOIN &COUNT(table.column) possible with Zend_Db_Query?

Just bumping this up to see if anyone has any input into this - I can't find
a way around this at all, and I'd have thought that queries like this were
quite common:

SELECT table1.table1ID,table1.someCol1,COUNT(table2ID) as someCount
FROM table1
LEFT JOIN table2 USING (table1ID)
GROUP BY table1.table1ID

which produces
+----------+---------------+-----------+
| table1ID | someCol1 | someCount |
+----------+---------------+-----------+
| 1 | table 1 row 1 | 3 |
| 2 | table 1 row 2 | 0 |
| 3 | table 1 row 3 | 1 |
+----------+---------------+-----------+


Thanks - I won't bump this again!
--
View this message in context: http://www.nabble.com/Queries-with-LEFT-JOIN--COUNT%28table.column%29-possible-with-Zend_Db_Query--tp22557518p22683989.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: