mysql - Count in query ruin expected result -
database structure
data
without count in query:
select id, test order asc limit 1
with count in query:
select id, a, count(*) test order asc limit 1
why happening? alternative?
try
select id, a, (select count(*) test) cnt test order asc limit 1
it should give expected results. though i'm pretty sure optimizer execute subquery once, makes sense check execution plan explain
.
Comments
Post a Comment