简体   繁体   English

为什么我的SQL查询失败?

[英]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' . 它总是会在ORDER BY RAND()LIMIT '10'上出现错误。

Any reason why this is happening? 出现这种情况的原因是什么? Also is there any solutions to this? 还有什么解决方案吗?

Limit should be integer? 限制应该是整数? 10 instead '10'. 而不是'10'。

SELECT *
FROM affiliate
ORDER BY RAND()
LIMIT 10 

Note there are no quotes around 10 注意10左右没有引号

The LIMIT parameter is a number, not a string: LIMIT参数是一个数字,而不是字符串:

SELECT * FROM users ORDER BY RAND() LIMIT 10

Whitout the quotes. 打开报价。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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