-1

I have a tabel named "intrebari" with fields "id" and "intrebare". How can I extract that in a table, but in random order?

dpaul1994
  • 332
  • 3
  • 16

5 Answers5

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
1

Use rand() function

SELECT * FROM table ORDER BY RAND();

Kaushik Maheta
  • 1,741
  • 1
  • 18
  • 27
0

Try this: use rand

SELECT * FROM `intrebari`
ORDER BY RAND()
Awlad Liton
  • 9,366
  • 2
  • 27
  • 53
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