A multiple-table query is relative to a single table, which refers to querying data from multiple data tables, where we mainly learn how to query data from two data tables.
4.3.1 Unconditional multiple Table query
An unconditional multiple table query is a combination of the records of each table in the form of "Cartesian" product.
If the Scott.dept table has 4 records, the Scott.emp table altogether has 14 records, its "Cartesian product" will have the 4*14=56 record.
In the command edit area, execute the following statement.
――――――――――――――――――――――――――――――――――――――
Select Emp.empno,emp.ename,emp.deptno,dept.dname,dept.loc from Scott.emp,scott.dept; ――――――――――――――――――――――――――――――――――――――
Click the Execute button to see the results shown in Figure 4.16.
"See CD-ROM File": \ 4th Chapter \4.3\431.sql.
4.3.2 equivalent multi-table query
In the command edit area, execute the following statement.
―――――――――――――――――――――――――――――――――――――
Select Emp.empno, Emp.ename, Emp.deptno, Dept.dname,dept.loc from Scott.emp,scott.dept where scott.emp.deptno=scott.de Pt.deptno;
―――――――――――――――――――――――――――――――――――――
Click the Execute button to see the results shown in Figure 4.17.
"See CD-ROM File": \ 4th Chapter \4.3\432.sql.
An equivalent multiple-table query queries the associated data in multiple data tables according to the equivalent criteria. Requires that some fields of the associated data table have the same properties, which have the same data type, width, and range of values.
4.3.3 Non-equivalence multi-table query
In the command edit area, execute the following statement.
―――――――――――――――――――――――――――――――――――――
Select Emp.empno, Emp.ename, Emp.deptno, Dept.dname,dept.loc from Scott.emp,scott.dept where SCOTT.EMP.DEPTNO!=SCOTT.D Ept.deptno and scott.emp.deptno=10; ―――――――――――――――――――――――――――――――――――――
Click the Execute button to see the results shown in Figure 4.18.
"See CD-ROM File": \ 4th Chapter \4.3\433.sql.
In a non-equivalence multiple table query, the reader can use the comparison operator shown in Table 4.1 to combine the query criteria.
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.