-2

尝试向此 sql 添加限制,它在限制之前工作正常,但是一旦我添加限制,我就会收到一条错误消息

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“LIMIT 0,10”附近使用正确的语法

我的 sql 是

SELECT a.id,a.product_name,a.product_price,a.user_id as product_user_id,b.id as user_id,b.first_name, FROM products as a, customers as b where a.user_id=b.id and a.product_featured='Y' and a.product_status='Active' order by a.id desc limit 0,6
4

4 回答 4

1

您有一个查询错误,不是限制,而是在FROM您放置逗号的关键字之前,。删除它,您的查询将运行。

你的查询是

SELECT a.id,a.product_name,a.product_price,a.user_id as product_user_id,b.id as user_id,b.first_name, FROM products as a, customers as b where a.user_id=b.id and a.product_featured='Y' and a.product_status='Active' order by a.id desc limit 0,6

将其更改为

SELECT a.id,a.product_name,a.product_price,a.user_id as product_user_id,b.id as user_id,b.first_name FROM products as a, customers as b where a.user_id=b.id and a.product_featured='Y' and a.product_status='Active' order by a.id desc limit 0,6

删除,关键字之前FROM

于 2012-11-23T07:55:21.083 回答
0

您将逗号放在错误的位置删除它,然后执行查询:

SELECT a.id,a.product_name,a.product_price,a.user_id AS product_user_id,b.id AS user_id,b.first_name**,** FROM products AS a, customers AS b WHERE a.user_id=b.id AND a.product_featured='Y' AND a.product_status='Active' ORDER BY a.id DESC LIMIT 0,6
于 2012-11-23T07:52:19.163 回答
0

From只需删除关键字前的逗号即可。

正确的查询将是

SELECT a.id,a.product_name,a.product_price,a.user_id as product_user_id,b.id as user_id,b.first_name FROM products as a, customers as b where a.user_id=b.id and a.product_featured='Y' and a.product_status='Active' order by a.id desc limit 0,6
于 2012-11-23T07:55:28.483 回答
0

解决了,没有意识到已经添加了限制

于 2012-11-23T07:55:43.513 回答