I'm having difficulties using the LEFT OUTER JOIN in multiple tables.
My tables are: countries
, customer_info
, package_types
, service_types
and shipping_info
This is my code so far:
$sql = "SELECT shipping_info.shipping_id, shipping_info.weight, shipping_info.width, shipping_info.height, shipping_info.length, shipping_info.cost, shipping_info.status,
service_types.service, package_types.package_type, countries1.country AS fromCountry, countries2.country AS toCountry, countries3.country AS resiCountry, customer_info.name, customer_info.address
, customer_info.city, customer_info.postcode, customer_info.zipcode, customer_info.phone, customer_info.email, customer_info.country
FROM shipping_info
LEFT OUTER JOIN service_types ON shipping_info.service_type = service_types.serviceType_id
LEFT OUTER JOIN package_types ON shipping_info.package_type = package_types.packageType_id
LEFT OUTER JOIN customer_info ON shipping_info.customer_id = customer_info.customer_id
LEFT OUTER JOIN countries AS countries1 ON shipping_info.from_loc = countries1.country_id
LEFT OUTER JOIN countries AS countries2 ON shipping_info.to_loc= countries2.country_id
LEFT OUTER JOIN countries AS countries3 ON shipping_info.to_id = countries3.country_id";
$statement = $con_db->query($sql);
$result = $statement->fetchAll();
I'm getting a fatal error in my final line and I believe that's because $result is null. But I'm unable to figure out the error.
Appreciate any help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…