<? $Query = "select * from tabla where campo1=3 having condicion order by(i_tabla)"; $Consulta = str_replace("where", "", strstr($Query, "where")); ?>