MySQL Forums
Forum List  »  Newbie

Re: MySQL Join 4 Tables
Posted by: Thames Muthu
Date: January 31, 2023 10:36AM

here it is again given bellow.
I have 4 tables as table A, table B, table C and table D. samples are given below.

Table A (ID, Des)-primary key is ID
=================
1&emspxxx
2&emspyyy
3&emspzzz
4&emspaaa

Table B (ID, P_ID)
==================
1&emspP01
3&emspP02

Table C (P_ID, P_DATE)-primary key is P_ID
======================
P01&emsp2022/10/12
P02&emsp2022/10/19

Table D (ID, REF_NO, D_DATE)
============================
2&emspB13&emsp2022/09/30
4&emspL84&emsp2022/09/22


and so on, I need to produce the following result using a query for a given criteria (ID). Query should produce either there are matching records in table C or D as follows.


A.ID&emspA.Des&emspC.P_DATE&emspC.ITEM_NO&emspD.REF_NO&emspD.D_DATE
1&emspxxx&emsp2022/10/12&emsp40&emsp________&emsp________
1&emspxxx&emsp2022/11/05&emsp03&emsp________&emsp________
3&emspzzz&emsp2022/10/19&emsp24&emsp________&emsp________
2&emspyyy&emsp_______&emsp________&emspB13&emsp2022/09/30
4&emspaaa&emsp_______&emsp________&emspL84&emsp2022/09/22

Options: ReplyQuote


Subject
Written By
Posted
January 29, 2023 11:48PM
January 30, 2023 07:25AM
January 31, 2023 08:26AM
Re: MySQL Join 4 Tables
January 31, 2023 10:36AM
February 01, 2023 07:23AM
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.