I have a tabel named "intrebari" with fields "id" and "intrebare". How can I extract that in a table, but in random order?
Asked
Active
Viewed 97 times
5 Answers
1
If you want to select the entire contents of the table:
SELECT * FROM `intrebari` ORDER BY RAND()
If however you only want a small subset of a large table, it may be more efficient to generate 5 random numbers in the range with php and use WHERE IN
instead

Steve
- 20,703
- 5
- 41
- 67
0
If you are asking about getting random result from the table randomly then you can try the following:
SELECT * FROM tbl_name ORDER BY RAND();
Hope this helps.

Techroshni
- 541
- 2
- 11
0
If you don't want to extract all records, and want to sort the randomly retrieved records, use,
SELECT * FROM (SELECT * FROM users ORDER BY rand() LIMIT 10) Tb ORDER BY id

sadiq.ali
- 526
- 1
- 6
- 16
-
Tb is just a table alias. Like we use in, select a.id, a.name from long_table_name a; – sadiq.ali Jul 17 '14 at 12:30