SQL statement to find multiple associated tables

Source: Internet
Author: User
I do not know the description clearly not, I hope that the predecessors pointing.



Reply to discussion (solution)

I do not know the description clearly not, I hope that the predecessors pointing.

SELECT * from a,b,c where a.ksbh = c.ksbh and A.xmbh = b.xmbh where b.tjdjbh = ' 10001041 ' and a.ksbh = ' 01 '//description is not clear enough; I don't know. Is this

SELECT * from a,b,c where a.ksbh = c.ksbh and A.xmbh = b.xmbh where b.tjdjbh = ' 10001041 ' and a.ksbh = ' 01 '//description is not clear enough; I don't know. Is this



The statement you provide has two where

Let's analyze it first.
Table IV communicates with the other three tables
The table four itself expresses:
What medical items are included in a comprehensive project (ZHBH,XMBH)
What medical items are included in a department (KSBH,XMBH)
What comprehensive projects are included in a department (KSBH,ZHBH)
The name of the medical item can be found in table xmbh by the table four.
The name of the medical item can also be found in table KSBH by the table four.
And the table four species of KSBH and Xmbh is one by one corresponding, so the KSBH in table one is superfluous
The KSBH in the third of the list is superfluous.
In table two, the user does the real check (XMBD) does not need to care about which Xmbh belongs to which ZHBH
So the ZHBH in table two is superfluous.
From the table around, we can know (through table four of Xmbh and Table II of the XMBH)
Some Xmbh were involved in the TJDJBH.
Some zhbh were involved in the TJDJBH.

Shouldn't the next thing be hard?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.