I have the following problem (simplified)
a table person with field personid related to table person_events with personid and eventid
another table events with eventid
A person can subscribe to many events from the events with the simple sql sentence
select personid from person p innner join person_events pe on p.personid=e.personid inner join events e on pe.eventid=e.eventid
In this way I can see a list of persons who subscribed for one or more particular events (I can use distinct to have one person)
But sometimes a person can subscribe to all events and, instead of putting everytime eventid 1,2,3,4 in the table person_events I want to make a code for the event for instance code 0. If I put code 0 in the table person_events I want to subscribe the person to all the events in the table events. If I put all codes from events in the table person_events I would off course have the same effect but I don't want that.
Is there a solution with conditional joins?