Lets say we a table t1 as
>desc t1;
id int
name varchar(30)
and
>select count(*) from t1;
count(*)
10
Is it possible to fetch the result as
id name count
1 abc 10
2 def 10
. . .
. . .
. . .
Where the actual result columns id name and the count of the result query count are in the same resultset. Is it possible that way?
The basic idea is to fetch the result row count along with the result, instead of having to query the database for the count separately. Even sub queries are also fine.
Thank you.
Yes, this is possible. It’s also quite efficient due to the way MySQL optimizes stuff