I have four tables, Photo, Event, News, Spot and Photo is the table i want to check for records with relations to other tables. 

Photo has the following sructure:

```
id
rel_model -> one of "news", "spot" and "event"
rel_id    -> id of the related record in rel_model table 
...

```

Tables other than Photo are constantly updated and some of the records ar deleted. I want to filter the photos to get the records that are related to existing records on other tables.

I tried the following 

```
select 
    count(*)
from
    Photo
        inner join Event ON (rel_id = Event.id and rel_model="event") 
        inner join News ON (rel_id = News.id and rel_model="news")
        inner join Spot ON (rel_id = Spot.id and rel_model="spot"); 

```

but I get 0 results where trying it with only one inner join works for checking against single table 

```
select 
    count(*)
from
    Photo
        inner join Event ON (rel_id = Event.id and rel_model="event") ;

```

I need to add some and-or logic inbetween inner joins, bit could not figure out how. 

How can I fetch the photos that still have unbroken relations to other tables?