sql >> Database teknologi >  >> RDS >> Mysql

sql join på to felter i én tabel

 SELECT 
       ag.id, 
       p.first_name, 
       p.last_name, 
       p.organisation, 
       p.event_date, 
       p.wave
 FROM (
      SELECT booking.person_1 as id, booking.Car as car FROM booking
      union ALL
      SELECT booking.person_2 as id, booking.Car as car FROM booking
     ) as ag
JOIN people p ON people.id = ag.id;
INNER | LEFT JOIN Cars c ON c.ID = ag.car


  1. Indlejrede klasser - CustomRowMapper !! Ikke et problem længere !! - Del 1

  2. Undgå tomme strenge i feltet CHARACTER VARYING

  3. Begræns daglig adgang

  4. Vil du forbinde SQL Server 2008 til Outlook-kalenderen?