Usage of standard SQL statements in mysql

Source: Internet
Author: User

Usage of standard SQL statements in mysql> set cascade update or delete: add constraint on delete cascade;> link query: syntax format: from TABLE1 join_type TABLE2 [on join_condition] [where query_condition] join_condition: Connection condition; query_condition: Query condition. * Cross join: returns the Cartesian product of all data rows in the join table without the on clause. For example, table 1 has five rows of data and table 2 has seven rows of data, the query result contains 35 (5*7) rows of data. Cross join example: select * from MERs, ORDERS; * inner join: returns the data rows in the connection table that meet the connection conditions and query conditions. * Outer join is divided into left outer join and right outer join ). Left Outer Join: return not only data rows that meet the connection and query conditions in the connection table, but also data rows that only meet the query conditions but do not meet the connection conditions in the left table. The outer right connection is similar to...> Subquery: a select query statement is nested in the select clause or where clause. Select * from MERs c where 3 <= (select count (*) from ORDERS o where c. ID = o. CUSTOMERS_ID); select * from ORDERS o where o. CUSTOMER_ID in (select ID from CUSTOMERS where NAME like 'Mike '); select * from CUSTOMERS c where not exists (select * from ........) Select NAME, AGE, (select sum (PRICE) from ORDERS where CUSTOMER_ID = 1) TOTAL_PRICE from CUSTOMERS where ID = 1;> Combined Query: combines the query results of two query statements, remove the duplicate data rows and return the query results without duplicate data rows. Select * from MERs where AGE <25 union select * from CUSTOMERS where AGE> = 24;> REPORT query: grouping statistics on data rows. Syntax format: [select...] from... [Where...] [group by... [having...] [order by...] group by specifies a group. The having clause sets the query conditions for a group. The aggregate functions used include count (), min (), max (), sum (), and avg (). Only select count (*) from TABLE1 is used to query the data; it is the fastest without the where condition. count (COLUMN) is not used. Mysql paging query: select COL from TABLE1 where... LIMIT 100,100 0 (from location 100, retrieving up to 1000 pieces of data) attach something useful: navicat10.1.0 latest key: NAVD-IO5R-4VGM-TIZD, NAVL-RK72-URYA-CINR

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.