Pagina 1 di 7 1 2 3 ... ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 62
  1. #1

    problema con ordinamento

    Ciao a tutti,
    devo ordinare dati estratti da DB in base ad un array.
    Vi spiego meglio:

    ho 2 array:
    codice:
    dim riferimentoinvernale(1000)
    dim prezzoinvernale(1000)
    tramite l'array riferimentoinvernale faccio la select nel DB, così:
    codice:
    		set rs = server.createObject("ADODB.Recordset") 
    		strq="select * from strutture where ((attiva = 'S') and (stato = 'A') and (durataminimasoggiorno <= " & ricercanotti & ") and (tipovacanza=" & chr(34) & ricercatipovacanza & chr(34) & ") and (tipostruttura=" & chr(34) & ricercatipostruttura & chr(34) & ") and (postiletto>=" & Cint(ricercaletti) & ") and (mappaprovincia like " & chr(34) & ricercaprovince & chr(34) & ") and (mappacomune like" & chr(34) & ricercacomuni & chr(34) & ") and (mappalocalita like " & chr(34) & ricercalocalita & chr(34) & ")"
    		'strq="select * from strutture where ((attiva = 'S') and (stato = 'A')"
    		
    		set rs2 = server.createObject("ADODB.Recordset") 
    		strq2 = "select count(*) as totrec from strutture where ((attiva = 'S') and (stato = 'A') and (durataminimasoggiorno <= " & ricercanotti & ") and (tipovacanza=" & chr(34) & ricercatipovacanza & chr(34) & ") and (tipostruttura=" & chr(34) & ricercatipostruttura & chr(34) & ") and (postiletto>=" & Cint(ricercaletti) & ") and (mappaprovincia like " & chr(34) & ricercaprovince & chr(34) & ") and (mappacomune like" & chr(34) & ricercacomuni & chr(34) & ") and (mappalocalita like" & chr(34) & ricercalocalita & chr(34) & ")"
    		'strq2 = "select count(*) as totrec from strutture where ((attiva = 'S') and (stato = 'A')"
    		
    		if x > 0 then
    			strq = strq & " and ("
    			strq2 = strq2 & " and ("
    		
    			for k = 0 to x-1
    				strq = strq & "(riferimento = '" & riferimentoinvernale(k) & "')"
    				strq2 = strq2 & "(riferimento = '" & riferimentoinvernale(k) & "')"
    				if x-1 > k then
    					strq = strq & " or "
    					strq2 = strq2 & " or "
    				end if
    			next		
    		
    			strq = strq & ")"
    			strq2 = strq2 & ")"
    		end if
    		strq = strq & ") order by id LIMIT "& inizio &", "& pageSize 
    		strq2 = strq2 & ")"
    Ora, vorrei ordinare la select in base all'array prezzoinvernale.
    Credo sia una cosa complicata... non mi è venuta nessuna soluzione funzionante in mente.

    Come potrei fare?

    Fatemi sapere.

    Grazie mille.

  2. #2
    puoi fare un esempio? grazie

  3. #3
    Ho un DB PRINCIPALE che ha vari campi tra i quali il campo riferimento:

    Es:
    M-05
    M-11
    M-08
    M-33
    M-07

    poi ho 2 array il primo arrayprezzo e il secondo arrayriferimento.
    Questi 2 array vengono creati recuperando dati da un altra tabella (l'array riferimento riporta i dati presenti nel campi riferimento del DB PRINCIPALE)

    Es:
    arrayprezzo

    25
    32
    10
    18
    55

    Arrayriferimento
    M-08
    M-07
    M-11
    M-33
    M-05

    Praticamente ordino gli arrayprezzo e arrayriferimento in base al primo quindi in ordine crescente per prezzo.

    quindi mi ritrovo i 2 array così:

    10 / M-11
    18 / M-33
    25 / M-08
    32 / M-07
    55 / M-05

    Ora: vorrei ordinare il DB PRINCIPALE in base ai riferimenti dell'array (a loro volta ordinati per prezzo)

    Spero di essere stato chiaro

    Fammi sapere.
    Grazie mille

    (sto valutando anche soluzioni alternative ma risultano complicate e lunghe)!!

  4. #4

  5. #5
    vorrei estrarre dal DB PRINCIPALE i dati in base al riferimento in quest'ordine:

    M-11
    M-33
    M-08
    M-07
    M-05

    mentre con un order by posso ordinarlo (credo) in ordine crescente o descescente in base ad uno dei campi del db stesso!!

  6. #6

  7. #7

  8. #8
    l'array di riferimento dove sta? puoi salvarlo in una tabella?

  9. #9
    L'array di riferimento lo genero prima di fare la select.
    L'array viene creato da un altra tabella.

  10. #10
    se l'array è in una tabella, metti questa tabella in join con l'altra e ordina di conseguenza...

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.