I have 4 tables below cluster, production, testcases, cluster_production_testcases
Cluster table
|id_cluster(PK)|cluster_name|Cluster_ipaddress|
|1 |a1 |10.x1.sss.xxx|
|2 |a1 |10.x2.sss.xxx|
|3 |a2 |10.x3.sss.xxx|
Production table
|ip_production(PK) | production_name|
|1 |Test1 |
|2 |Test2 |
TestCases table
|id_testcases(PK)|testcase_name|ip_production(FK)|
|1 |Hello1 |1 |
|2 |Hello2 |1 |
|3 |Hello2 |2 |
Cluster_Production_Testcases
|id_cpt(PK) | id_cluster(FK) | id_production(FK) |
|1 | 1 | 1 |
|2 | 2 | 1 |
|3 | 1 | 2 |
|4 | 2 | 2 |
How to get cluster_name
, cluster_ipaddress
, production_name
and testcase_name
which all are links together using primary and foreign key using cluster_production_testcases
table.
Try using implicit (you could use ANSI as well) join:
SELECT c.cluster_name, c.cluster_ipaddress, p.production_name, t.testcase_name
FROM Cluster c, Production p, Testcases t, Cluster_production_Testcases cpt
WHERE cpt.id_cluster = c.id_cluster
AND cpt.id_production = p.ip_production
AND p.ip_production = t.ip_production
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.