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

Discussione: Select da più tabelle

  1. #1

    Select da più tabelle

    eccomi qua ciao ...
    allora ho questo dilemma:
    devo fare una select da più tabelle

    Codice PHP:
    <%
    struttura=Request.querystring("tipos")
    if 
    struttura "" then
    struttura
    =(",2,13,14,23,19,21,3,")
    else
    struttura = (","&struttura&",")
    end if
    %>


    strSQL "select  * from hotel_es where hotel_es.city_hotel like '"&replace(nomecitta,"'","''")&"%' or hotel_es.city_preferred like '"&replace(nomecitta,"'","''")&"%' and tipo_strutture.hoteltype_id (IN) "&struttura&" order by hotel_es.minrate asc,hotel_es.id" 
    praticamente io dalla tabella hotel_es vorrei estarre gli id che nella tabella tipo_strutture campo hoteltype_id hanno 2 o 13 o 14 in base alla querystring passata ..

    Stampa della query:
    select * from hotel_es where hotel_es.city_hotel like 'Barcellona%' or hotel_es.city_preferred like 'Barcellona%' and tipo_strutture.hoteltype_id IN ,2,13,14,23,19,21,3, order by hotel_es.minrate asc,hotel_es.id


    errore:
    Microsoft JET Database Engine (0x80040E14)
    Errore di sintassi (operatore mancante) nell'espressione della query 'hotel_es.city_hotel like 'Barcellona%' or hotel_es.city_preferred like 'Barcellona%' and tipo_strutture.hoteltype_id (IN) ,2,13,14,23,19,21,3,'.

    :master:

  2. #2
    Utente di HTML.it L'avatar di wallrider
    Registrato dal
    Apr 2003
    Messaggi
    2,755
    non ho capito come sono legate
    hotel_es e tipo_strutture
    RIP Cicciobenzina 9/11/2010

    "Riseminaciceli, i ceci nell'orto"

  3. #3
    la tabella hotel_es ha il campo id che corrisponde nella
    tabella tipo_strutture con il campo hotel_id

  4. #4
    ho fatto un piccolo passo:

    Codice PHP:
    <% 
    struttura=Request.querystring("tipos"
    if 
    struttura "" then 
    struttura
    =(",2,13,14,23,19,21,3,"
    else 
    struttura = (","&struttura&","
    end if 
    %> 

    "SELECT * FROM hotel_es AS h, tipo_strutture AS t WHERE "&_
    "h.id = t.hotel_id and h.city_hotel like'"&replace(nomecitta,"'","''")&"%' and t.hoteltype_id= '14' order by h.minrate asc,h.id" 
    così sembra funzionare ora però vorrei sostituire
    t.hoteltype_id='14' con t.hoteltype_id contiene struttura vorre anche fare in modo di fav visualizzare i dati della tabella hotel_es anche se non trova corrispondenze su t.hoteltype_id .. ho provato con left outer join ma ho sempre errori ...

    un piccolo aiuto ...

  5. #5

  6. #6
    Utente di HTML.it L'avatar di wallrider
    Registrato dal
    Apr 2003
    Messaggi
    2,755
    Originariamente inviato da slay
    prova a rileggere il tuo precedente post e immagina di essere qualcuno del forum che non ne sa nulla del tuo progetto
    RIP Cicciobenzina 9/11/2010

    "Riseminaciceli, i ceci nell'orto"

  7. #7
    Originariamente inviato da slay
    facci un disegno

  8. #8
    sembrava chiaro cmq ok reset completo .. allora inziamo per passi ho questo codice:

    Codice PHP:

    <% 
    struttura=Request.querystring("tipos"
    if 
    struttura "" then 
    struttura
    =(",2,13,14,23,19,21,3,"
    else 
    struttura = (","&struttura&","
    end if 
    %> 

    "SELECT * FROM hotel_es AS h, tipo_strutture AS t WHERE "&
    "h.id = t.hotel_id and h.city_hotel like'"&replace(nomecitta,"'","''")&"%' and t.hoteltype_id= '14' order by h.minrate asc,h.id" 

    il codice funziona così come l'ho messo .. io vorrei sostituire t.hoteltype_id= '14' in questo modo:

    t.hoteltype_id contiene i numeri presenti in 'struttura'

    'struttura' è una variabile passata tramite quesrystring formata in questo modo es: 2,13,14
    non so se mi sono spiegato ..

  9. #9
    ... and t.hoteltype_id in '" & struttura & "' ...

  10. #10
    ciao optime lunedì provo poi ti dico mi sembrava di aver già provato con "and in" e mi dava un errore bahh..... cmq lunedì provo grazie ancora ..

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.