Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 14

Discussione: Errore sql UNION

  1. #1

    Errore sql UNION

    Ciao a tutti,
    potete dare un occhiata a quanto segue per capire dove sto sbagliando?

    codice:
    strq = "select * from casa where abilitato='S' and lmgiugno='S' order by areadiriferimento, posizione, nome" 
    strq = strq & " UNION ( select * from casa where (abilitato='S' and lmluglio='S' order by areadiriferimento, posizione, nome))"
    strq = strq & " UNION ( select * from casa where (abilitato='S' and lmagosto='S' order by areadiriferimento, posizione, nome))"
    strq = strq & " UNION ( select * from casa where (abilitato='S' and lmsettembre='S' order by areadiriferimento, posizione, nome))"
    questo è ciò che mi restituisce:
    codice:
    select * from casa where abilitato='S' and lmgiugno='S' order by areadiriferimento, posizione, nome UNION ( select * from casa where (abilitato='S' and lmluglio='S' order by areadiriferimento, posizione, nome)) UNION ( select * from casa where (abilitato='S' and lmagosto='S' order by areadiriferimento, posizione, nome)) UNION ( select * from casa where (abilitato='S' and lmsettembre='S' order by areadiriferimento, posizione, nome)) LIMIT 0, 10 
    Microsoft OLE DB Provider for ODBC Drivers error '80040e21' 
    
    ODBC driver does not support the requested properties. 
    
    /elenco offerte lastminute2.asp, line 80
    Fatemi sapere.
    Grazie mille.

  2. #2

  3. #3

  4. #4
    Ho già usato la UNION con questi db e ha funzionato... ora però non riesco a eliminare l'errore!!

  5. #5
    Ciao Optime, ho ritrovato una discussione sull'argomento che stavamo facendo diverso tempo fa al seguente indirizzo:http://forum.html.it/forum/showthrea...n&pagenumber=1

    Mi sa che sto risolvendo!!

  6. #6
    Problema non risolto con count:
    codice:
    strq2 = "select count(*) from (select count(*) as totrec from casa where abilitato='S' and lmgiugno='S')t1"
    strq = strq & " UNION select count(*) from( select count(*) as totrec from casa where abilitato='S' and lmluglio='S')t2"
    strq = strq & " UNION select count(*) from( select count(*) as totrec from casa where abilitato='S' and lmagosto='S')t2"
    strq = strq & " UNION select count(*) from( select count(*) as totrec from casa where abilitato='S' and lmsettembre='S')t2"
    Praticamente il risultato di record trovati è errato.
    Cosa sto sbagliando?

  7. #7
    Ti riporto anche ciò che voglio ottenere, magari c'è qualche altro metodo:
    ho una tabella con i campi LMgiugno, LMluglio, LMagosto, LMsettembre.
    Praticamente se uno di questi campi ha valore S il conto totale dei record trovati deve aumentare (fino a 4 per ogni record effettivo).

    Es: record 1 ha tutti e 4 i campi con valore S così come record 2 e record 3... il risultato finale di record trovati deve essere pari a 12.
    Spero di essermi spiegato bene.

    Fammi sapere.

  8. #8
    ... in effetti potrei fare 4 select count separate e otterrei il risultato che voglio!
    Fammi sapere se la soluzione UNION è praticabile altrimenti faccio tutto separatamente!!

  9. #9
    sto continuando la discussione da solo...
    comunque:

    io vorrei che la seguente select mi estraesse 4 campi (è sempre la prima che ho postato però ora non da l'errore) è possibile?
    codice:
    strq = "select * from (select * from casa where abilitato='S' and lmgiugno='S' order by areadiriferimento, posizione, nome)t1" 
    strq = strq & " UNION select * from (select * from casa where abilitato='S' and lmluglio='S' order by areadiriferimento, posizione, nome)t2"
    strq = strq & " UNION select * from (select * from casa where abilitato='S' and lmagosto='S' order by areadiriferimento, posizione, nome)t2"
    strq = strq & " UNION select * from (select * from casa where abilitato='S' and lmsettembre='S' order by areadiriferimento, posizione, nome)t2"
    Mi sa che non mi sta funzionando!!

    Come posso risolvere?

  10. #10

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.