Hi,
I would like to create a MySQL Select Statement,using Joins to join 3 tables.
Currently in my Code, I have the two Table join working great:
- SELECT
- traveldocuments.TDNumber,
- traveldocuments.TDMoveStart,
- traveldocuments.TD_ODR_O_Address,
- traveldocuments.TD_ODR_D_Address,
- approvals.ApprovalJurisdictionFee,
- approvals.ApprovalPermitFee
- FROM traveldocuments
- Left JOIN approvals
- ON (traveldocuments.Id=approvals.TDId);
So I was doing some searching, and I can see examples from other languages (Java), that I should be able to just add on the third table, but it errors out (not in code but in the DBMS), this is what I tried to change it to:
- SELECT
- traveldocuments.TDNumber,
- traveldocuments.TDMoveStart,
- traveldocuments.TD_ODR_O_Address,
- traveldocuments.TD_ODR_D_Address,
- approvals.ApprovalJurisdictionFee,
- approvals.ApprovalPermitNowFee,
- commodities.CommoditySteerUnitNumber
- FROM traveldocuments
- Left JOIN approvals
- ON (traveldocuments.Id=approvals.TDId);
- LEFT JOIN commodities
- ON (traveldocuments.Id=commodities.TDId);
The specific error is Unknown column : 'commodities.CommoditySeerUnitNumber' in 'field list'
I know this table and column exist, when I'm building the statement in HeidiSQL, it autocompletes the column name, and I've printed out my table columns and I can see it there.
I have a Foreign Key in the commodities table setup exactly the same way as the approvals table, it's almost like a parent/child setup.
Any suggestions would be appreciated.
Thank you!