I have a table tbl with 3 columns imp_col, data1, data2 where imp_col's type is enum('imp1', 'imp2, 'imp3', 'imp4'). Now if I want to select 10 rows randomly I can do like this.
select imp_col, data1, data2 from tbl where imp_col in ('imp1', 'imp2', 'imp3') limit 10 order by rand();
But in this case all the 10 resulting rows may have imp_col as imp1.
Is there an SQL query which can return 10 rows with imp_col distributed evenly among imp1, imp2, imp3?
Thanks.
Are you able to use limit and rand() in an inline view in mySQL?
That would give you a better chance of getting a variety of ‘imp’ values, if it’s legal.