我有 5 个表,我希望从所有链接到名为 pubs 的表中获取数据。
special_offers 有 3 条与 pub 相关的记录 events 有 4 条与 pub 相关的记录
但是,我只取回了第一个事件和 special_offers。它似乎没有构造成多级数组。我试过加入和内部加入,我看不出有什么问题。
SELECT pubs.*, special_offers.*, `events`.*, vote.*
FROM pubs
Inner Join `events`
ON pubs.id = `events`.pubID
Inner Join special_offers
ON pubs.id = special_offers.pubID
Inner Join vote
ON pubs.id = vote.pubID
WHERE pubs.id = 48
这是 print_r 的输出
Array (
[0] => 48
[id] => 1 Harveys
[name] => Harveys
[sun] => 10am-2.30am
[31] => 1
[32] => 4
[special_dayID] => 4
[33] => 48
[pubID] => 48
[34] => 2.50 Drinks
[title] => Kodakid
[35] => All drink 2.50 get them while there hot! or cold!
[desc] => Kodakid are playing!
[36] => 1
[37] => 48
[38] => 2012-04-30
[date] => 2012-04-30
[39] => Kodakid
[40] => & others
[subtitle] => & others
[41] => Kodakid are playing!
[42] => kodakid.jpg
[img] => kodakid.jpg
[43] => 1
[44] => 48
[45] => 3
[price_range] => 3
[46] => 5
[atmosphere] => 5
[47] => 2
[food] => 2
[48] => 4
[service] => 4
[49] => 3
[value] => 3
[50] => Waterford City
[county] => Waterford City )
谢谢