I want to show only 15% of all records using mysql, all I see is a way to show only a specific number of rows. Is there a way to do such thing.
Thanks in advance.
I want to show only 15% of all records using mysql, all I see is a way to show only a specific number of rows. Is there a way to do such thing.
Thanks in advance.
You probably need to calculate it by yourself like
declare var int;
select var = (count(*) * .15) from mytable;
select * from mytable
order by id
limit 1, var;
You can also use SQL_SELECT_LIMIT
option like below. Got from this thread Variable LIMIT Clause in MySQL
Set SQL_SELECT_LIMIT = var;
select * from mytable
order by id;