Subquery statement example:

Source: Internet
Author: User
Tags dname
1. Use subquery In the create table statement

By using subqueries In the create table statement, you can insert data in the table while creating a new table. SQL> Create Table dept1 (deptno, dname, Loc) as select deptno, dname, LOC from Dept; if it is to create all columns, you can use * to simplify the statement. SQL> Create Table emp1 as select * from EMP; 2. Use the subquery SQL in the update Statement> Update emp1 set (SAL, comm) = (select Sal, comm from emp1 where enmae = 'ward ') where job = (select job from emp1 where enmae = 'ward '); 3. Use the subquery SQL> Delete emp1 where deptno = (select deptno from dept1 where dname = 'accounting') in the delete statement '); 4. Using subqueries in an insert statement by using subqueries in an insert statement, you can insert datasets in one table into another table. SQL> insert into emp1 select * from EMP where deptno = (select deptno from Dept where dname = 'accounting ');

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.