5
我想寫出下面使用的查詢,其中方法如何在Ruby on Rails中編寫嵌套查詢?
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"))
請幫