Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135

    Esecuzione query multiple

    Ciao; ho alternativa nella costruzione di questo codice?:
    codice:
    Dim strConnection, myConn, rs
    
    	Set myConn = Server.CreateObject("ADODB.Connection")
    	myConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../../mdb-database/db.mdb")
    	
        strSQL = "SELECT sum(n_somma) as tot2000 FROM tabellaPR WHERE programma = 2000"
        set rs = server.createObject("ADODB.Recordset")
        rs.open strSQL, myConn, 1, 3
        pr_2000 = rs("tot2000")
        response.write pr_2000 &"
    
    "
        rs.close
        set rs = nothing
        
        strSQL = "SELECT sum(n_somma) as tot2001 FROM tabellaPR WHERE programma = 2001"
        set rs = server.createObject("ADODB.Recordset")
        rs.open strSQL, myConn, 1, 3
        pr_2001 = rs("tot2001")
        response.write pr_2001&"
    
    "
        rs.close
        set rs = nothing
        
        strSQL = "SELECT sum(n_somma) as tot2002 FROM tabellaPR WHERE programma = 2002"
        set rs = server.createObject("ADODB.Recordset")
        rs.open strSQL, myConn, 1, 3
        pr_2002 = rs("tot2002")
        response.write pr_2002 &"
    
    "
    Devo necessariamente eseguire tutte queste query o c'è un metodo più veloce?

    Grazie

  2. #2

  3. #3
    usa la clausola GROUP BY

  4. #4
    Utente di HTML.it L'avatar di [trodat]
    Registrato dal
    Oct 2004
    Messaggi
    2,135
    Originariamente inviato da optime
    usa la clausola GROUP BY

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.