I do not know the description of the SQL statements for multiple associated tables.
Reply to discussion (solution)
I do not know whether the description is clear or not.
Select * from a, B, c where. KSBH = C. KSBH and. XMBH = B. XMBH where B. TJDJBH = '000000' and. KSBH = '01' // The description is not clear enough.
Select * from a, B, c where. KSBH = C. KSBH and. XMBH = B. XMBH where B. TJDJBH = '000000' and. KSBH = '01' // The description is not clear enough.
The statement you provide has two where
Let's analyze it first.
Table 4 communicates with the other three tables
Table 4 itself expresses:
What health check items are included in a comprehensive project (ZHBH, XMBH)
What health check items are included in a department (KSBH, XMBH)
What comprehensive projects are included in a department (KSBH, ZHBH)
The name of the health check item can be found in Table 4 XMBH.
Similarly, the name of the health check item can be found in Table 4's KSBH.
The four types of KSBH in table correspond to XMBH one by one, so the KSBH in Table 1 is redundant.
Similarly, the KSBH in Table 3 is redundant.
In table 2, the user does a real check (XMBD) and does not need to care about which ZHBH the XMBH belongs.
Therefore, ZHBH in table 2 is redundant.
From the table, we can know (through XMBH in Table 4 and XMBH in table 2)
An XMBH is involved by TJDJBH.
A zhbh is involved by TJDJBH.
The next thing should be difficult, right?