Ver Mensaje Individual
  #4 (permalink)  
Antiguo 11/09/2012, 07:22
jurena
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Cáceres
Mensajes: 3.735
Antigüedad: 16 años, 1 mes
Puntos: 300
Respuesta: consulta a dos tablas con campos iguales

¿Has probado así?
(select SQL_CALC_FOUND_ROWS nombre,fecha from tabla1
where nombre='pepe' and edad<'20' group by LIMIT 0,5)
union all
(select SQL_CALC_FOUND_ROWS nombre,fecha from tabla2
where nombre='pepe' and edad<'20' group by id desc LIMIT 0,5)
order by id desc

Por cierto, por qué agrupas por id. No parece tener sentido pues el id es diferente en una tabla y no estás usando ninguna función de agrupado, tipo SUM, AVG, etc.
Tal vez así obtendrás lo mismo
(select SQL_CALC_FOUND_ROWS id, nombre,fecha from tabla1
where nombre='pepe' and edad<'20' LIMIT 0,5)
union all
(select SQL_CALC_FOUND_ROWS id, nombre,fecha from tabla2
where nombre='pepe' and edad<'20' LIMIT 0,5)
order by id desc

Última edición por jurena; 11/09/2012 a las 08:17