########################多表########################
SELECT COUNT(*) FROM MEMBER1 A;
Check out the results for the 43 rows of data;
SELECT COUNT(*) FROM LOAN B;
Check out the results for the 13 rows of data;
A set of Cartesian * # B, that is to say the number of rows and the number of rows in Table A Table B multiplication result obtained, as a result the line 43 * 13 = 559, the following two statements
SELECT COUNT(*) FROM MEMBER1 A,LOAN B;
SELECT * FROM MEMBER1 A INNER JOIN LOAN B;
# Implicit within the connector, the query result matching condition, the data line 13;
SELECT A.ID,A.REGNAME,A.LEAVEAMOUNT,B.ID,B.TITLE,B.AMOUNT FROM MEMBER1 A,LOAN B WHERE A.ID = B.MEMBERID;
Connecting the inner and outer joins difference #:
# Connection to query all the matching data
# outer connecting the main data table will be displayed, the data from the matching table is displayed
# Display ON the connection concerned is how to associate the table, WHERE concerns screening results, as shown below:
不带where 条件情况:
SELECT A.ID,A.REGNAME,A.LEAVEAMOUNT,B.ID,B.MEMBERID,B.TITLE,B.AMOUNT FROM MEMBER1 A INNER JOIN LOAN B ON A.ID = B.MEMBERID;
Conditions with where:
# Connecting left outer, left table is the primary table, the table is from the right table
SELECT A.ID,A.REGNAME,A.LEAVEAMOUNT,B.ID,B.TITLE,B.AMOUNT
FROM MEMBER1 A LEFT JOIN LOAN B ON B.MEMBERID = A.ID;
# Right outer join, the left table from the table, the right table is the primary table
SELECT A.ID,A.REGNAME,A.LEAVEAMOUNT,B.ID,B.TITLE,B.AMOUNT
FROM MEMBER1 A RIGHT JOIN LOAN B ON B.MEMBERID = A.ID;
# Left outer join query data does not match
SELECT A.ID,A.REGNAME,A.LEAVEAMOUNT,B.ID,B.TITLE,B.AMOUNT
FROM LOAN B LEFT JOIN MEMBER1 A ON B.MEMBERID = A.ID WHERE A.ID IS NULL ;