MySQL SELECT COUNT(*) FROM issue with LIMIT
Recently working on my core database class I found an issue with my num_of_rows() method. I was parsing my query to do various things, which basically boiled down to running a query like: [code]SELECT COUNT(*) FROM `table_name`[/code] To return the number of rows generated by this query. Now, when I started introducing pagination in my front end, I wanted to utilise LIMIT/OFFSET in my queries, like so; [code]SELECT COUNT(*) FROM `table_name` LIMIT 30, 10[/code] Which I would hope returned 10 (or less if I had less than 30 rows in my table. Anyway, this was throwing a wobbler in my PDO class, I wasn't getting any error or feedback that there was an issue, and in phpmyadmin I was simply getting " MySQL returned an empty result set (i.e. zero rows) ". Baffled, I took to google and found this work around: [code]SELECT COUNT(*) FROM (SELECT * FROM `projects` LIMIT 30,10) AS subquery[/code] Happy coding