php - Solving count query issue -
i have following code need select items personabisna table , count items same personalbisnaid table both tables share personalbisnaid
$query="select c.businesslogo, c.personalbisnaid, c.account_id, ads personalbisna c inner join myads b on b.personalbisnaid=c.personalbisnaid group c.personalbisnaid limit $itemfrom,$dataperpage";
these tables
personalbisna table
| personalbisnaid| account_id| businesslogo --------------------------------------------- | 1 | 23 | qwertyu.jpg | 2 | 4 | asdfghjk.jpg | 3 | 12 | 34567gfd.jpg | 4 | 34 | drtyujhv.jpg
myads table
| myadsid | personalbisnaid| adtype --------------------------------------------- | 1 | 2 | logo | 2 | 2 | business card | 3 | 3 | logo | 4 | 2 | caricalture
i have used answered questions solve problem , i'm getting totally confused solve issue
the above query should output following
| personalbisnaid| account_id| businesslogo | adscount ------------------------------------------------------- | 1 | 23 | qwertyu.jpg | 0 | 2 | 4 | asdfghjk.jpg | 3 | 3 | 12 | 34567gfd.jpg | 1 | 4 | 34 | drtyujhv.jpg | 0
this have
$query="select c.businesslogo, c.personalbisnaid, c.account_id, c.businessname, c.businesscategory, c.businesssubcategory, c.town, c.estate, c.street, c.road, c.building, c.address, c.city, c.phonenumber, c.altphonenumber, c.website, c.email, c.businesstype count(myadsid) adscount personalbisna c left outer join myads b on b.personalbisnaid= c.personalbisnaid group c.personalbisnaid limit $itemfrom,$dataperpage";
count
aggregate missing in query.
also if want select items personabisna
table instead of inner join
need left/right outer join
select c.personalbisnaid, c.account_id, c.businesslogo, count(adtype) adscount personalbisna c left outer join myads b on b.personalbisnaid=c.personalbisnaid group c.personalbisnaid, c.account_id, c.businesslogo
Comments
Post a Comment