MySQL Forums
Forum List  »  Newbie

Re: MySQL Join 4 Tables
Posted by: Thames Muthu
Date: February 02, 2023 12:17AM

Thanks Phillip
It works pretty fine until both tables (Table C and Table D) have matching records. But failed to produce result when there are no matching records in either Table C or Table D.

select
A.ID
, A.Des
, C.P_DATE
, C.ITEM_NO
, D.REF_NO
, D.D_DATE
from table_a A
left join table_b B
on A.ID = B.ID
left join table_c C
on B.P_ID = C.P_ID
left join table_d D
on A.ID = D.ID
where A.ID = 1

** I wrote a Union Query that works pretty fine by adding criteria for each set.

kind regards

Options: ReplyQuote


Subject
Written By
Posted
January 29, 2023 11:48PM
January 30, 2023 07:25AM
January 31, 2023 08:26AM
January 31, 2023 10:36AM
February 01, 2023 07:23AM
Re: MySQL Join 4 Tables
February 02, 2023 12:17AM
February 06, 2023 08:16AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.