Hi, does anyone know how to display all the rows in a query from two tables.
Eg. I have join_tbl_LoadCommodity_OptionType and join_tbl_DispatchHist_OptionType. They both have a jobId and loadId field.
table 1 has 321 records, and table2 has 16 records
if I do the following, I get 5000+ records
SELECT join_tbl_LoadCommodity_OptionType.*, join_tbl_DispatchHist_OptionType.*
FROM join_tbl_LoadCommodity_OptionType, join_tbl_DispatchHist_OptionType;
if I add the load table and set conditions for the job and loadId based on each table:
SELECT join_tbl_LoadCommodity_OptionType.*, join_tbl_DispatchHist_OptionType.*, join_tbl_DispatchHist_OptionType.jobId, join_tbl_DispatchHist_OptionType.loadId, join_tbl_LoadCommodity_OptionType.jobId, join_tbl_LoadCommodity_OptionType.loadId
FROM (join_tbl_LoadCommodity_OptionType RIGHT JOIN tbl_Load ON (join_tbl_LoadCommodity_OptionType.loadId = tbl_Load.loadId) AND (join_tbl_LoadCommodity_OptionType.jobId = tbl_Load.jobId)) LEFT JOIN join_tbl_DispatchHist_OptionType ON (tbl_Load.loadId = join_tbl_DispatchHist_OptionType.loadId) AND (tbl_Load.jobId = join_tbl_DispatchHist_OptionType.jobId)
WHERE (((join_tbl_DispatchHist_OptionType.jobId) Is Not Null) AND ((join_tbl_DispatchHist_OptionType.loadId) Is Not Null)) OR (((join_tbl_LoadCommodity_OptionType.jobId) Is Not Null) AND ((join_tbl_LoadCommodity_OptionType.loadId) Is Not Null));
I get 335 records, but there should be 337.
There are 2 records that share a job and loadId and the query is placing all of the data into one row instead of splitting them up into two rows. Can anyone help please? thank you
Eg. I have join_tbl_LoadCommodity_OptionType and join_tbl_DispatchHist_OptionType. They both have a jobId and loadId field.
table 1 has 321 records, and table2 has 16 records
if I do the following, I get 5000+ records
SELECT join_tbl_LoadCommodity_OptionType.*, join_tbl_DispatchHist_OptionType.*
FROM join_tbl_LoadCommodity_OptionType, join_tbl_DispatchHist_OptionType;
if I add the load table and set conditions for the job and loadId based on each table:
SELECT join_tbl_LoadCommodity_OptionType.*, join_tbl_DispatchHist_OptionType.*, join_tbl_DispatchHist_OptionType.jobId, join_tbl_DispatchHist_OptionType.loadId, join_tbl_LoadCommodity_OptionType.jobId, join_tbl_LoadCommodity_OptionType.loadId
FROM (join_tbl_LoadCommodity_OptionType RIGHT JOIN tbl_Load ON (join_tbl_LoadCommodity_OptionType.loadId = tbl_Load.loadId) AND (join_tbl_LoadCommodity_OptionType.jobId = tbl_Load.jobId)) LEFT JOIN join_tbl_DispatchHist_OptionType ON (tbl_Load.loadId = join_tbl_DispatchHist_OptionType.loadId) AND (tbl_Load.jobId = join_tbl_DispatchHist_OptionType.jobId)
WHERE (((join_tbl_DispatchHist_OptionType.jobId) Is Not Null) AND ((join_tbl_DispatchHist_OptionType.loadId) Is Not Null)) OR (((join_tbl_LoadCommodity_OptionType.jobId) Is Not Null) AND ((join_tbl_LoadCommodity_OptionType.loadId) Is Not Null));
I get 335 records, but there should be 337.
There are 2 records that share a job and loadId and the query is placing all of the data into one row instead of splitting them up into two rows. Can anyone help please? thank you