我有四张桌子(目的地、度假村、酒店和多中心)。在多中心表中,我有 36 列与其他三个表相关。有没有办法可以使用内部连接将四个表连接在一起?
到目前为止,我有以下内容:
function getMultiCentres() {
$db = new Db();
$sql = "SELECT * FROM multicentres INNER JOIN destinations ON multicentres.destinationid_1 = destinations.destinationid AND multicentres.destinationid_2 = destinations.destinationid AND multicentres.destinationid_3 = destinations.destinationid AND multicentres.destinationid_4 = destinations.destinationid AND multicentres.destinationid_5 = destinations.destinationid AND multicentres.destinationid_6 = destinations.destinationid AND multicentres.destinationid_7 = destinations.destinationid AND multicentres.destinationid_8 = destinations.destinationid AND multicentres.destinationid_9 = destinations.destinationid AND multicentres.destinationid_10 = destinations.destinationid AND multicentres.destinationid_11 = destinations.destinationid AND multicentres.destinationid_12 = destinations.destinationid
INNER JOIN resorts ON multicentres.resortid_1 = resorts.resortid AND multicentres.resortid_2 = resorts.resortid AND multicentres.resortid_3 = resorts.resortid AND multicentres.resortid_4 = resorts.resortid AND multicentres.resortid_5 = resorts.resortid AND multicentres.resortid_6 = resorts.resortid AND multicentres.resortid_7 = resorts.resortid AND multicentres.resortid_8 = resorts.resortid AND multicentres.resortid_9 = resorts.resortid AND multicentres.resortid_10 = resorts.resortid AND multicentres.resortid_11 = resorts.resortid AND multicentres.resortid_12 = resorts.resortid
INNER JOIN hotels ON multicentres.hotelid_1 = hotels.hotelid AND multicentres.hotelid_2 = hotels.hotelid AND multicentres.hotelid_3 = hotels.hotelid AND multicentres.hotelid_4 = hotels.hotelid AND multicentres.hotelid_5 = hotels.hotelid AND multicentres.hotelid_6 = hotels.hotelid AND multicentres.hotelid_7 = hotels.hotelid AND multicentres.hotelid_8 = hotels.hotelid AND multicentres.hotelid_9 = hotels.hotelid AND multicentres.hotelid_10 = hotels.hotelid AND multicentres.hotelid_11 = hotels.hotelid AND multicentres.hotelid_12 = hotels.hotelid
";
$multicentres = $db -> select($sql);
return $multicentres;
}