Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- problem with mysql fetch array


rocknbil - 5:30 pm on Jul 27, 2010 (gmt 0)


Why can't this work, eliminating the first select entirely?

select (select count(*) from novice_komentarji where novice_komentarji.novicaID=novice.id) as postcount, novice.id, novice.naslov from novice;


| postcount | id | naslov |
+-----------+----+---------------------+
| 5 | 1 | This is title one |
| 2 | 2 | This is title two |
| 0 | 3 | This is title three |
| 5 | 4 | This is title four |
+-----------+----+---------------------+
4 rows in set (0.01 sec)


I'm not sure what you're doing with max, and there may be a more efficient could than a nested select, but that makes life a little easier.


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4175730.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com