Reputation: 4190
This isn't a complete question, but I was just wondering if there was a better or more elegant way to set a variable to the count of the number of rows from a mysql select
statement. Currently, what I have is:
SET @myCount =
(SELECT COUNT(*)
FROM table1
WHERE aCondition = TRUE);
Upvotes: 0
Views: 299
Reputation: 60493
you can use a select... into
(donnow if you find this more "elegant")
select count(*) into @myCount
from table1
where aCondiction = TRUE;
Upvotes: 1