Hi Guys!
I have two tables like this.
Table 1 Fields: CId , Name Table 2 Fields: CId , food
I want to get no. of food against each CId with the query "select * from table1"
Hi Guys!
I have two tables like this.
Table 1 Fields: CId , Name Table 2 Fields: CId , food
I want to get no. of food against each CId with the query "select * from table1"
Something like that should work:
SELECT
t1.* , count(t2.food) as foods
FROM
t1 LEFT JOIN t2 on (t1.Cid = t2.Cid)
GROUP BY
t2.Cid