Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Select complessa

  1. #1

    Select complessa

    Ciao ho bisogno di fare una select complessa

    questo è il codice:

    Codice PHP:
    sql_hotelcitta "select top 10 * from hotel_es where city_hotel like '"&replace(nomecitta,"'","''")&"%' order by minrate asc,id"
    sql_hotelcitta "select top 10 * from hotel_es where city_hotel like '"&replace(nomecitta,"'","''")&"%' order by minrate desc,id"
    sql_hotelcitta "select top 10 * from hotel_es where class=1 and city_hotel like '"&replace(nomecitta,"'","''")&"%' order by minrate asc,id"
    sql_hotelcitta "select top 10 * from hotel_es where class=2 and city_hotel like '"&replace(nomecitta,"'","''")&"%' order by minrate asc,id"
    sql_hotelcitta "select top 10 * from hotel_es where class=3 and city_hotel like '"&replace(nomecitta,"'","''")&"%' order by minrate asc,id"
    sql_hotelcitta "select top 10 * from hotel_es where class=4 and city_hotel like '"&replace(nomecitta,"'","''")&"%' order by minrate asc,id"
    sql_hotelcitta "select top 10 * from hotel_es where class=5 and city_hotel like '"&replace(nomecitta,"'","''")&"%' order by minrate asc,id" 
    Se faccio le varie select separate una ad una funziona tutto il problema sta nel fatto che (ovviamente) alcuni record vengono ripetuti come potrei fare in modo da non ripete i record?

  2. #2
    avevo pensato di creare un array e di mettere gli id e in caso id fosse già presente nell'array non faccio niente altrimenti stampo il record .. ci può stare?

  3. #3
    oppure ogni ulteriore queri dovrebbe avere un "id not in (select id from tabella where condizioni_precedenti)" e quindi fai fare il lavoro al db..buh
    IP-PBX management: http://www.easypbx.it

    Old account: 2126 messages
    Oldest account: 3559 messages

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.