Review of SQL statements in database

Source: Internet
Author: User

/* a property (xx) in table t is repeated n times so record. Eg: the name repeats more than 3 times in table a so record. Idea: First find out more than 3 times the name of what, and then the records of these names extracted. */select * from A where name in (select Name Form A GROUP by name has count (name) >3)


/* Query for the nth to M Records in table A (id,name): 31st to 40th record in table */mysql:: Select * from A limit 30, 10; (limit in MySQL)//Find out the first 30 ID, and then find out the first 10 select top of the 30. From a where ID not in (select top IDs from a))

Student Information Form S (sno,sname,age,sex) number, name, age and Gender Course Information Table SC (SNO,CNO, Scgrade) number, course number, grade course Information Form C (CNO,CNAME,CT) Course number, course name, Instructor also elective course name   Student number and name//analysis for "1" and "2" Students: the course name can correspond to the unique course number, the student number corresponds to the unique student information, and finally the relationship is concentrated in SC to select Sno, sname from S where Sno in (select Sc.sno from Sc,c where Sc.cno=c.cno and CNAME in (' 1 ', ' 2 ') group by Sno Count (distinct CNO) =2);


Review of SQL statements in database

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.