$subquery = " image.id IN ( SELECT " . $alias . ".image_id FROM " . $table . " AS " . $alias . " WHERE ";