MySQL Forums
Forum List  »  Italian

problemi con UNION
Posted by: Alberto Del Corona
Date: October 15, 2014 11:16AM

Salve a tutti, (la mia prima richiesta di aiuto)
ho 2 query che, singolarmente funzionano perfettamente e mostrano gli stessi campi ma, messe in UNION non funzionano.
Pensando che la causa potesse derivare dai diversi tipi negli stessi campi delle due query ho anche fatto in modo che fossero sempre di tipo string per tutti i campi ma l'UNION continua a non funzionare
Riporto di seguito le 2 query saltando qualche pezzo non significativo e senza conversione di tipo per non appesantire troppo i testi (che sono molto pesanti).
Da tenere presente che alcune tabelle (ultimi_dati11, dositab_test11, dositot_test11) sono di tipo TEMPORARY.
Mi potete suggerire qualche motivo per il quale le due query assieme non funzionano?
Grazie

alberto


query1:

SELECT CF_Crypt,Cognome_Crypt, _Nome_Crypt, Sede,Anno,dositab_test11.Tipo, gen, feb, mar, apr, mag, giu, lug, ago, sep, ott, nov, dic
FROM anagrafica
left join ultimi_dati11 ON ultimi_dati11.LINK = Id_anag
left join dositab_test11 on dositab_test11.LINK = Id_anag
left join dositot_test11 ON dositot_test11.LINK = Id_anag
left join (select .......) as AL ON (AL.LINK=Id_anag AND AL.Tipo=dositab_test11.Tipo)
WHERE DOMINIO='test' AND dositab_test11.Anno =2012 AND dositot_test11.Tipo = dositab_test11.Tipo

query2:

SELECT CF_Crypt,Cognome_Crypt, _Nome_Crypt, Sede,2012 as Anno, T2.Tipo as 'Tipo',' ' as 'gen',' ' as 'feb',' ' as 'mar',' ' as 'apr',' ' as 'mag',' ' as 'giu',' ' as 'lug',' ' as 'ago',' ' as 'sep',' ' as 'ott',' ' as 'nov',' ' as 'dic'
from anagrafica,
ultimi_dati11,
(select .......) T2
WHERE DOMINIO='test' and ultimi_dati11.LINK=Id_anag and T2.LINK=Id_anag and concat(T2.LINK,T2.Tipo) NOT IN (select .........) having T2.uSv_al<>''

Options: ReplyQuote


Subject
Views
Written By
Posted
problemi con UNION
1766
October 15, 2014 11:16AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.