Oracle BASIC SQL Statement-Query Chapter

Source: Internet
Author: User

I. GENERAL Enquiry

/* Query table data */
SELECT * FROM STU

/* Remove the first 3 rows of data */
SELECT * from Stu where rownum<=3


/* Fuzzy query */
SELECT * from Stu where stu_id like ' stu001% '

Description: The wildcard "%" represents one or more characters, and the wildcard "_" represents one character.

/* Alias */
Select stu_id as study number from STU

Second, joint inquiry
/* General Union Query */
SELECT STU. Stu_name, STU. Stu_age, KC. Kc_name from STU, KC WHERE STU. Kc_no = KC. Kc_no


/* Union query */
SELECT STU. Stu_name, STU. Stu_age, KC. Kc_name from STU INNER JOIN in KC on STU. Kc_no = KC. Kc_no ORDER by STU. stu_id


/* Left connection */
SELECT STU. Stu_name, STU. Stu_age, KC. Kc_name from STU left JOIN in KC on STU. Kc_no = KC. Kc_no ORDER by STU. stu_id


/* Right Connection */
SELECT STU. Stu_name, STU. Stu_age, KC. Kc_name from STU right JOIN KC on STU. Kc_no = KC. Kc_no ORDER by STU. stu_id


/* Full Connection */
SELECT STU. Stu_name, STU. Stu_age, KC. Kc_name from STU full JOIN in KC on STU. Kc_no = KC. Kc_no ORDER by STU. stu_id


/*union keyword, Union of two tables some fields */
Select Stu_name from STU UNION SELECT kc_name from KC

Related Article

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.