Unknown column 't.group_id' in 'where clause' Query: SELECT DISTINCT c.id AS id, c.name AS name FROM tours_categories AS c, tours_groups AS g, tours AS t, tours_date AS d, tours_places AS p WHERE p.date_id = d.id && d.startdate > CURDATE() && d.tour_id = t.id && t.group_id = g.id && g.category_id = c.id