faqts : Computers : Databases : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 31 people (42%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

Imagine 2 tables:t1(id int autoinc)(data:1,2,3...),t2(id int)(1,2,2,1,1...) Need query to get t1.id & count(t2.id)where t1.id=t2.id. t2.id CAN BE NUL!

Nov 21st, 2008 22:30
haytham ali, dman, Richard Mitchell, Pasha Rudy, http://sturly.com


select   t1.id, count(t2.id)
from     t1 left join t2
on       t1.id = t2.id
group by t1.id

http://6rb.com
http://fr7.com
http://dir.msryat.org
http://6ef.com
http://forums.msryat.org
http://www.arabcar.com