0

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.

tadman
  • 208,517
  • 23
  • 234
  • 262

1 Answers1

1

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;
Community
  • 1
  • 1
Rahul
  • 76,197
  • 13
  • 71
  • 125