i want write a query for the following using where method
SELECT * FROM videos
WHERE 'privacy' = 'public' OR
(privacy = 'private' AND
id IN (SELECT vid
FROM vid_ads
WHERE 'aid'=#{current_id}))
I tried using following query but ended with a syntax error
Video.where("privacy = 'public' OR
(privacy = 'private' AND id = ?)",
VidAd.where(:aid => current_id).select("vid"))
Please help
hopefully this shud work!
Video.where("category = #{@static_cat} AND
privacy = 'public' OR
(privacy = 'private' AND
id IN (?))",
VidAd.where(:aid => current_id).select("vid"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With