Reputation: 2561
I want to fetch 50 random records without duplication.
Table Name : table 1
Fields : test_id,test_name,test_phone.
Can anyone suggests me query that can fetch 50 random records from database without duplication?
Upvotes: 0
Views: 124
Reputation: 11552
Try:
SELECT DISTINCT * FROM table_1 ORDER BY RAND() LIMIT 50;
Do make sure that they're unique, make sure that test_id
is an auto-increment INT
.
Upvotes: 2
Reputation: 698
Try this
SELECT DISTINCT * FROM table ORDER BY RAND() LIMIT 50
Contact if you have any doubt.
Upvotes: -2
Reputation: 2265
use the following query
SELECT distinct * FROM `table_1` order by rand() limit 50
it works.
Upvotes: 1