SELECT * FROM index_db
inner join media on index_db.mid = media.ID
inner join media_mid on media_mid.pid = media.ID
inner join media_type on media_type.code = media_mid.RESOURCE_TYPE
inner join media_place on media_place.code = media_mid.place
WHERE media_type.media_type_side_bar_search = 'yes' and group by index_db.id