mysql - Sql Query returns single row, but not all -
i trying records single sql query. there many records in database returns 1 row.
for example: returns record no. 1. if delete record returns record no. 2. there many records. want display records.
here query.
select camp.title, camp.status, c.name, b.base_id, count(s.base_id) subscribers campaigns camp join company c on c.id = camp.company_id join campaign_numbers b on b.campaign_id = camp.id join base_numbers s on s.base_id = b.base_id camp.campaign_date = '2017-04-07' , camp.approved = 1
what want query return campaigns
current date
2017-04-07
, approved
status should 1
query returning single row, not campaigns.
if this, returns all..
select title, status campaigns campaign_date = '2017-04-07' , approved = 1
but want show company name , want count subscribers too. doing wrong?
you have aggregation function in select
no group by
. in databases, return error. in mysql, aggregation query returns 1 row.
presumably want group by
:
group camp.title, camp.status, c.name, b.base_id
Comments
Post a Comment