-2

このSQLに制限を追加しようとすると、制限の前は正常に機能していましたが、制限を追加するとすぐに、次のようなエラーが発生します。

SQL構文にエラーがあります。1行目の「LIMIT0,10」の近くで使用する正しい構文については、MySQLサーバーのバージョンに対応するマニュアルを確認してください。

私の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

limit ではなくクエリ エラーがありますが、キーワードの前に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 に答える