CREATE TEMPORARY TABLE temp (SELECT * FROM tbl WHERE a = b); select count(*) FROM temp union (SELECT * FROM temp)
CREATE TEMPORARY TABLE temp (SELECT * FROM tbl ); SET @a = (select count(*) FROM temp); select @a union (SELECT * FROM temp)