php - How to write a query that selects 9 rows randomly from database?
652
SELECT * FROM tbl_specialisation
WHERE LENGTH(spec_specialise) < 20 ORDER BY spec_specialise LIMIT 9
add to this query
SELECT * FROM tbl_specialisation
WHERE LENGTH(spec_specialise) < 20 ORDER BY spec_specialise LIMIT 9
add to this query
People are also looking for solutions to the problem: php - show custom fields data in next and previous link in wordpress
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
Find the answer in similar questions on our website.
Answer
Solution:
"SELECT * FROM
tbl_specialisation
WHERE LENGTH(spec_specialise) < 20 ORDER BY RAND() LIMIT 9 ";Answer
Solution:
USE
ORDER BY RAND()
Answer
Solution:
Your question is not clear because you are asking 9 random fields but in SQL query you are trying to get 9 records. If you want to get 9 records from table then use following.