There are 3 tables
The table name CPFileList
CpFileNo cpState
F1 A
F2 A
F3 B
F4 B
F5 C
F6 C
The table name CPOutList1
CpOutNo cpClient
D1 customer 1
D2 customer 2
D3 client 3
The table name CPOutList2
CpOutNo cpFileNo
D1 f1
D1 f2
D2 f3
D2 f4
D3 F5
D3 f6
How about in SQL according to the given cpState value and find out the corresponding cpOutNo cpClient value are
I now use is such a query
The SELECT cpOutNo FROM CPOutList1 WHERE cpClient='1' clients AND cpOutNo IN (SELECT cpOutNo FROM CPOutList2 WHERE cpFileNo IN (SELECT cpFileNo FROM CPFileList WHERE cpState='A'))
Because I am a novice, for the use of the SQL also is not very good
Don't know if it used IN the method of query is reasonable, isn't it more regular usage
Want to know about the, everyone in this table is how to check more,
Which way is more commonly used, query speed, high efficiency,
CodePudding user response:
If a small amount of data, use in there is no problem, if the data amount reaches a certain level, such as more than 1 w, had better not use inDon't write specific code, you can see the inner join, assistance in SQL query analyzer has.
CodePudding user response:
SELECT CPOutList1 cpOutNo As Final_OutNo, CPFileList. CpFileNo, CPOutList2. CpOutNo, CPFileList2. CpFileNo FROM CPOutList, CPOutList1, CPOutList2 WHERE CPOutList1. CpOutNo=CPOutList2. CpOutNo And CPFileList. CpFileNo=CPFileList2. CpFileNo And cpClient='1' customers And cpState='A'CodePudding user response:
Hello of123Want to ask
SELECT a. *, a. * FROM a INNER JOIN ON a.a 1 b=a.a 1
SELECT a. *, a. * FROM the WHERE a.a=b.b 1
What's the difference between the two kinds of query methods, ah, with INNER JOIN and the WHERE condition, which is faster
CodePudding user response:
http://download.csdn.net/detail/veron_04/1644211CodePudding user response:
http://download.csdn.net/detail/veron_04/1644211Here didn't find the content about SQL
CodePudding user response:
The