Ver Mensaje Individual
  #3 (permalink)  
Antiguo 04/08/2009, 14:03
Twonex
 
Fecha de Ingreso: julio-2009
Ubicación: .mysql_error ( XD )
Mensajes: 554
Antigüedad: 15 años, 7 meses
Puntos: 13
Respuesta: Cómo unir 2 consultas?

si lo intente con UNION, pero no me funciono.
el codigo seria:

Código PHP:
$consul "(SELECT * FROM valorreal
        INNER JOIN valoracumulado ON valorreal.categorias = valoracumulado.categorias
        AND valorreal.ano = valoracumulado.ano
        AND valorreal.mes = valoracumulado.mes
        AND valorreal.tipo = valoracumulado.tipo
        WHERE valorreal.ano='$anio' AND valorreal.mes='$mess' AND valorreal.tipo='Gastos')
        UNION (SELECT * FROM categorias WHERE tipo='Gastos')"
;
        
$resul mysql_query ($consul) or die ("Error en consulta:".mysql_error());
        
        while (
$fila mysql_fetch_array($resul)) 
pero no me funciona
me da el siguiente error
y no cacho que onda...

Error en consulta:The used SELECT statements have a different number of columns

saludos