I have the following schema enter image description here

so if the user wants the video to be private he sends '1' while adding the video, So that the video is available to only that particular user

If the users chooses 0 then the video is made available to all users.

Here is sample data: enter image description here

I have a large set of information, and so i want to query only 20-20 records using limit

Query i tried

select * from test where userid="2" and public/private ="0"

But this will return only one record i.e videoid='1'

If i query like

select * from test where userid=4 and public/private='1'

i also want videoid 1,2 as result as they are public

Hope you understand what i mean! Can you help me to design the query..

有帮助吗?

解决方案

So you want all private listings for that user and and all public listings for any user

select * from test where userid="2" or public/private ="0"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top