You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and (provincia='bariloche' or ciudad = 'bariloche') AND activo='s' order BY pr d' at line 1->SELECT id FROM gh_hoteles WHERE and (provincia='bariloche' or ciudad = 'bariloche') AND activo='s' order BY pr desc,ficha desc limit 0,10