0
私は各項目の各ユーザのスコア情報を含むdbテーブルを持っています。私は、ユーザーが見ていないアイテム(ショッピングカートやウィッシュリストに追加されていない)のスコアを取得したいと考えています。 私はこのクエリがあります:複数のテーブルからデータを取得するmysql php
$query = $this->db->query("
select product_id
, score
from score where (customer_id= '$customer_id' and product_id not in (
(select product_id from cart where customer_id= '$customer_id')
UNION
(select product_id from customer_wishlist where customer_id= '$customer_id')
))
order by score desc
limit 4");
を、私は、次の致命的なエラー持っている:
Uncaught exception 'Exception' with message 'Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNION (select product_id from customer_wishlist where customer_id= '8')))
任意の助けを?
がクロージングを取り除くと、開口部がUNIONの両側を括弧選択する選択UNIONの周り)(役に立たない使用していない場合は – Strawberry
そして、パラメトリッククエリについては – Strawberry
@Strawberryありがとうございます – user2148116