MySQL Count returns More Rows than it Should -
MySQL Count returns More Rows than it Should -
i attempting count number of rows given query. count returns more rows should. happening?
this query returns 1 row.
select * `opportunities` inner bring together `companies` on `opportunities`.`company_id` = `companies`.`id` left bring together `opportunitytags` on `opportunities`.`id` = `opportunitytags`.`opportunity_id` `opportunities`.`ispublished` = '1' , `opportunities`.`company_id` = '1' grouping `opportunities`.`id` ; this query returns there 3 rows.
select count(*) aggregate `opportunities` inner bring together `companies` on `opportunities`.`company_id` = `companies`.`id` left bring together `opportunitytags` on `opportunities`.`id` = `opportunitytags`.`opportunity_id` `opportunities`.`ispublished` = '1' , `opportunities`.`company_id` = '1' grouping `opportunities`.`id`;
when select count(*) counting before grouping by. can (unfortunately realm sql server , don't have mysql instance test) prepare using over() function.
for example:
select count(*) on (partition `opportunities`.`id`) edit: doesn't available in mysql, bad. how wrapping whole thing in new select statement? it's not elegant solution, give figure you're after.
mysql count rows
Comments
Post a Comment