我想使用where where
编写以下查询SELECT * FROM videos
WHERE 'privacy' = 'public' OR
(privacy = 'private' AND
id IN (SELECT vid
FROM vid_ads
WHERE 'aid'=#{current_id}))
我尝试使用以下查询,但以语法错误结束
Video.where("privacy = 'public' OR
(privacy = 'private' AND id = ?)",
VidAd.where(:aid => current_id).select("vid"))
请帮忙
答案 0 :(得分:2)
希望这个糟糕的工作!
Video.where("category = #{@static_cat} AND
privacy = 'public' OR
(privacy = 'private' AND
id IN (?))",
VidAd.where(:aid => current_id).select("vid"))