mounika Posted November 7, 2006 Share Posted November 7, 2006 HI,Can any one tell what should be the query to count from two tables where we have to get zero count for null.Ex:[b]Table 1: Table 2:[/b][b]ID Name ID Subjects Table1ID [/b] 1 abc 1 English 1 2 xyz 2 Maths 13 mno 3 Science 1Result should be:[b]Name count(subjects)[/b]abc 3xyz 0mno 0Thanks in Advance! Link to comment https://forums.phpfreaks.com/topic/26409-get-multiple-zero-count/ Share on other sites More sharing options...
fenway Posted November 7, 2006 Share Posted November 7, 2006 Try the following (UNTESTED):[code]SELECT t1.name, COUNT(t2.id)FROM t1 LEFT JOIN t2 ON ( t2.table1id = t1.id )GROUP BY t1.id[/code] Link to comment https://forums.phpfreaks.com/topic/26409-get-multiple-zero-count/#findComment-120899 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.