I'm using SQL joins from three child tables, to form one table, and that works fine.
However, I would like to pull the name of a customer from a table that is a parent, in the same SQL statement.
Here is the code to my working Three Table Join:
SELECT
traveldocuments.TDNumber,
traveldocuments.TDMoveStart,
traveldocuments.TD_ODR_O_Address,
traveldocuments.TD_ODR_D_Address,
approvals.ApprovalJurisdictionFee,
approvals.ApprovalPermitNowFee,
commodities.CommoditySteerUnitNumber,
commodities.CommodityName
FROM traveldocuments
LEFT JOIN approvals ON (traveldocuments.Id=approvals.TDId)
LEFT JOIN commodities ON (traveldocuments.Id=commodities.TDId);
I tried adding the field: customers.CustomerName, and another Join: LEFT JOIN customers ON (traveldocuments.ID=customers.ID);
But all I get are NULL values in the Joined Column, instead of the Customer Names.
So I'm not sure how to get the Name of the Customer, corresponding to the TDId. With the other tables, approvals and commodities, they are child tables, but the now the Customers is a parent Table to traveldocuments.
Any help would be appreciated.
Thank you!
G
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.