MySQL Forums
Forum List  »  General

join 4 tables
Posted by: Jerry Duenas
Date: May 19, 2020 11:34AM

Good day. I have four tables that I would like to pull data from and create a report without having to query every single table multiple times. Here is the scenario
Table a: poiid, poiref, poictry
Table b: pdref, pddesc,pdmp, pdtool,pdlen,pdod,pdid
Table c: ctryid, ctrycode1,ctrycode2,ctrycode3
Table d: mpid, mplen
poiref = pdref
poictry = ctryid
pdmp = mpid

When I enter poiid I am trying to populate a table that cascades the information from every table. Table a provides the information that table b needs. Table c takes the information from table a. Table d takes the information from table b.
So far I have done:
select * from a where poiid = x;
key1 = rs.getString("pdref");
key2 = rs.getString("poictry");
select * from c where ctryid = key2;
select * from b where pdref = key1;
key3 = rs.getString("pdmp");
select * from d where mpid = key4;
and then I use this information for further processing and passing it to a holding table in java prior to creating reports or displaying on the dashboards.
Is there a way to do a join and pull all of this information. On single query is fine but sometimes we have a range of queries all based on table a. Your assistance in guiding me along this process is greatly appreciated

Options: ReplyQuote

Written By
join 4 tables
May 19, 2020 11:34AM
May 19, 2020 12:43PM

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.