How to limit by percentage of all rows in MySQL?
I was trying this:
SELECT * FROM table_name
ORDER BY column_name ASC
LIMIT (SELECT ROUND(COUNT(id)*0.25) FROM table_name)
I also tried to save query SELECT ROUND(COUNT(id)*0.25) FROM table_name
to variable, but it was the same problem. I know that LIMIT require only number, but I don't know how many rows are in table to give specific number to LIMIT. How to do this without LIMIT if it isn't possible with LIMIT?
I need to SELECT only top 25 % of all rows in table.