Here’s my query:
SELECT *
FROM designs AS d
LEFT JOIN categories AS c
ON d.category = c.category
GROUP BY d.name ASC LIMIT 0, 10
I’d like return the number of rows found WITHOUT the limit condition in place. Here’s my line of thinking:
SELECT SQL_CALC_FOUND_ROWS '0', *
FROM designs AS d
LEFT JOIN categories AS c
ON d.category = c.category
GROUP BY d.name ASC LIMIT 0, 10
UNION
SELECT '1', FOUND_ROWS()
This doesn’t work. I get a column # mismatch. How would I modify the query to work?
Your first select, is a:
I don’t know how many columns ‘*’ is (at least 3, d.category, d.name, c.category), but your second query (after the union) should have the same number of columns. Now you only return two columns in your second query.
I also saw in the documentation, you should use an UNION ALL instead of UNION, I quote: