Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    query: ordinare su più campi

    Col seguente codice i dati vengono ordinati in ordine di cognome. Come faccio ad ordinarli per più campi (es. per cognome, poi per nome e poi per data di nascita? Grazie.

    <%
    orderType = Request.QueryString("orderType")
    ascDescType = Request.QueryString("ascDescType")
    If orderType <> "name" AND orderType <> "authority" Then
    orderType = "cognome"
    End If
    If ascDescType <> "DESC" Then
    ascType = "ASC"
    End If

    'Creo una nuova stringa SQL
    validateSQL = "SELECT * FROM tbl_Authors ORDER BY " & orderType & " " & ascDescType

    'Creo un nuovo recordsheet
    Set rs_userlist = Server.CreateObject ("ADODB.RecordSet")

    'Apro il record sheet e eseguo SQL
    rs_userlist.open validateSQL,adoCon
    %>
    Schumi di Roma

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    codice:
    orderType = "cognome, nome, data_nascita"
    L'eventuale DESC allo stato attuale sarebbe applicato però solo all'ultimo campo.

    Roby

  3. #3
    Grazie mille, va bene così.
    Schumi di Roma

  4. #4
    Come faccio a stabilire che il campo dataregistrazione (campo data e ora) deve essere elencato in ordine decrescente (dall'ultimo registrato al più vecchio)?
    Scusate ma non sono molto pratico.
    Grazie.

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <%
    orderType = Request.QueryString("orderType")
    ascDescType = Request.QueryString("ascDescType")
    If orderType <> "name" AND orderType <> "authority" Then
    orderType = "dataregistrazione"
    End If
    If ascDescType <> "DESC" Then
    ascType = "ASC"
    End If

    'Creo una nuova stringa SQL
    validateSQL = "SELECT * FROM tbl_Authors ORDER BY " & orderType & " " & ascDescType

    'Creo un nuovo recordsheet
    Set rs_userlist = Server.CreateObject ("ADODB.RecordSet")

    'Apro il record sheet e eseguo SQL
    rs_userlist.open validateSQL,adoCon
    %>
    Schumi di Roma

  5. #5
    Ho risolto da solo.

    Grazie.
    Schumi di Roma

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 © 2026 vBulletin Solutions, Inc. All rights reserved.