-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
  • 340
  • 3
  • 15

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,091
  • 5
  • 39
  • 64
1

Use rand() function

SELECT * FROM table ORDER BY RAND();

Kaushik Maheta
  • 1,645
  • 1
  • 16
  • 27
0

Try this: use rand

SELECT * FROM `intrebari`
ORDER BY RAND()
Awlad Liton
  • 9,260
  • 2
  • 26
  • 50
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
  • 511
  • 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
  • 496
  • 1
  • 5
  • 16