简体   繁体   中英

Why does my SQL query fail?

I'm using this to retrieve information from a database, the query always brings errors

This is my query:

SELECT * FROM users ORDER BY RAND() LIMIT '10'

It always brings up errors on either the ORDER BY RAND() or the LIMIT '10' .

Any reason why this is happening? Also is there any solutions to this?

Limit should be integer? 10 instead '10'.

SELECT *
FROM affiliate
ORDER BY RAND()
LIMIT 10 

Note there are no quotes around 10

The LIMIT parameter is a number, not a string:

SELECT * FROM users ORDER BY RAND() LIMIT 10

Whitout the quotes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM