SELECT Schedule.*, Performers.Name, Venues.Name
FROM Schedule
INNER JOIN Venues ON Schedule.VenueID=Venues.id
INNER JOIN Performers ON Schedule.PerformerID=Performers.id
WHERE Performers.Name='Bearslap'
ORDER BY Venues.id ASC
这将返回Schedule中的所有列,Venues中的Name列,但不返回Performers中的Name列:
Array (
[id] => 10
[VenueID] => 1
[Day] => SAT
[Start] => 07:00:00
[End] => 09:00:00
[PerformerID] => 4
[Date] =>
[Notes] =>
[Name] => Timeout
)
切换内连接的顺序没有区别
我不能说我理解这一点,但问题与我在表演者和场地表中都有一个'名字'栏有关。当我给他们唯一的名字(PName,VName)时,问题就消失了。我正在使用MySQL。