I want that i random 5 data from my table but i want that the value "orange" is always displayed in this random and "orange" also rand with them , sow how to do that?
select fruits from table ORDER BY rand() limit 5;
I want that i random 5 data from my table but i want that the value "orange" is always displayed in this random and "orange" also rand with them , sow how to do that?
select fruits from table ORDER BY rand() limit 5;
You can select orange separately:
(select fruits from table where name = 'orange')
union all
(select fruits from table where name <> 'orange' order by rand() limit 4)
order by rand()
You can do this using:
select t.fruits
from table t
order by (case when t.fruit = 'orange' then 1 else 2 end),
rand()
limit 5;