I have 2 tables events and events_visibility
events table and the column
id - title - all
events_visibility and its column
id - event_id - visibile_to - visibile_to_id
here visibile_to used who can see this events. here visibile to maybe Group A, Group B, Group C, so one event can have multiple entry in event_visibility
SELECT Event.*, EventVisibility.* FROM events AS Event
LEFT JOIN events_visibility AS EventVisibility
ON
(Event.id = EventVisibility.event_id)
WHERE
'Event.all' = 1
OR
(
'EventVisibility.visible_to_id' = 2 AND
'EventVisibility.visible_to' = 159
)
I want to fetch the unique events based on the visibility and if all, something like this
this query not gave me the proper result.
Can you please take a look.
Its maybe you wrote column inside single quotes. Try this