MySQL query syntax

Source: Internet
Author: User


Select distinct ProductName from Custom_
Where Product_price between 5 and 10
Order by product_price Desc, product_name
Limit 3 offset 1;

The limit limit starts at 1 rows and selects 3 rows, and the default column starts with 0 columns.

A semicolon or \g represents the end of a statement
Help or \h for assistance
Quit or exit
Distinct function with all subsequent columns, cannot be partially used
Query order default ascending ASC (Ascend)

The default A and a are treated in the same order,

* Replace all Columns


The Order by is placed after the where

MySQL default is case insensitive

In a condition, a string comparison needs to be quoted, and a comparison with a numeric value does not

NULL, when a match is selected, the system does not match its value, that is, it does not return

2016/12/25 6:39

where ID in (11,13)
where ID not in (11,13)

Wildcard characters:
where pro_name like ' jet% ' style matches the product name at the beginning of jet
(Case sensitive)
Wildcard: '%jet% ' in the middle contains jet
% represents any character, 0 or more characters, but does not match a null
_ Match a single character

Note
Wildcards less efficient than other searches

Regular Expressions:
where Pro_name REGEXP ' regular ' returns rows containing a conforming expression style
Case-sensitive plus binary keywords such as where pro_name REGEXP binary '. 000 '
MySQL's key word escape is ' \ \ ': \ \. Said. \\--\\\ means \
(MySQL itself explains a \, the regular explains a \.) )
Note
where Pro_name REGEXP ' 1000 ' returns a line that has a value of ' 1000 ' matches the substring
where pro_name like ' 1000 ' has no wildcard character and nothing returns like matches the entire string

Calculate word string:
Stitching function: Concat (,,) such as Select Concat (Vend_name, ' (', Vend_counytry, ') ') from Vendos order by Vend_name
Back to: ACME (USA)
Trim () Remove spaces
As assignment to other columns
Operations: Select pro_id, Quantity, Item_price,
Quantity*item_price= Expanded_price
from OrderItems;

Text-handling functions:
Select Vend_name, Upper (Vend_name) as Vend_name_upcase
from vendors;
Rtrim () to the right of the space


MySQL query syntax

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.