Visualizzazione dei risultati da 1 a 4 su 4

Discussione: sql distinct e join...

  1. #1

    sql distinct e join...

    Ciao ragazzi,
    quale è l'errore in questa SQL?

    codice:
    SELECT DISTINCT(tab_eventi_utenti.id_utente), tab_eventi_utenti.id_evento, tab_eventi_utenti.ID_eventi_utenti, tab_utenti.user_utente, tab_utenti.foto_utente FROM tab_eventi_utenti RIGHT JOIN tab_utenti ON tab_eventi_utenti.id_utente = tab_utenti.ID_utenti WHERE tab_eventi_utenti.id_evento = " & id_evento
    In pratica non mi funziona il distinct e mi mostra cmq tutti i risultati presente nella tabella per quel tab_eventi_utenti.id_utente

    Grazie

  2. #2
    DISTINCT fa la DISTINCT su TUTTI i campi della SELECT....

  3. #3
    giusto...

    Ho fatto così e sembra essere corretto il risultato

    SELECT DISTINCT tutto.user_utente, tutto.foto_utente, id_utente
    FROM(
    SELECT tab_eventi_utenti.id_utente, tab_eventi_utenti.id_evento, tab_eventi_utenti.ID_eventi_utenti,
    tab_utenti.user_utente, tab_utenti.foto_utente
    FROM tab_eventi_utenti
    RIGHT JOIN tab_utenti
    ON tab_eventi_utenti.id_utente = tab_utenti.ID_utenti
    WHERE tab_eventi_utenti.id_evento = 2) AS tutto
    forse c'era un modo piu semplice?

  4. #4

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.