All pastes #240782 Raw Edit

Something

public text v1 · immutable
·published 2006-11-05 22:08 UTC
rendered paste body
// Does not work
SELECT Performances.Date, Performances.MovieName, Performances.TheaterName, COUNT(Reservation.Number) as takenSeats, Theaters.Seats as totSeats
FROM Performances, Theaters
LEFT JOIN Reservation USING (PerfId)
WHERE Theaters.Name=Performances.TheaterName
GROUP BY Reservation.PerfId;

ERROR 1054 (42S22): Unknown column 'PerfId' in 'from clause'

// Works fine
SELECT Performances.Date, Performances.MovieName, Performances.TheaterName, COUNT(Reservation.Number) as takenSeats, Theaters.Seats as totSeats
FROM Performances
LEFT JOIN Reservation USING (PerfId)
LEFT JOIN Theaters ON Theaters.Name = Performances.TheaterName
GROUP BY Reservation.PerfId;