Summary of SELECT usage in Mysql database _mysql

Source: Internet
Author: User

First, conditional screening

1. Digital filter: sql = "SELECT * from [sheet1$] Where sales price > 100"

2. Character condition: sql = "SELECT * from [sheet1$] Where Object name = ' Fender '"

3. Date condition: sql = "SELECT * from [sheet1$] Where Object name = ' Fender '"

4, interval conditions: sql = "SELECT * from [sheet1$] Where out of the library date between #2005 -1-4# and #2005 -1-10#"

5. Multiple conditions: Connect with And,or

' sql = ' select * from [sheet1$] Where out of the library date between #2005 -1-4# and #2005 -1-10# and sales price >100 "

6, fuzzy conditions:% of any number of characters, _ (underline) represents a single placeholder

' sql = ' select * from [sheet1$] Where item name like '% armrest% '

7. Insert Variable query:

' sr = ' fender '
' sql = ' select * from [sheet1$] Where Object name = ' & sr & ' '

8, in the string group:

' sql = ' select * from [sheet1$] Where object name in (' Garment ', ' armrest ') '

9, Borrow function optimization:

' sql = ' select * from [sheet1$] Where left (item code, 3) = ' 028 ' "

Second, specify the filter

1. Filter all fields: * represents all fields

' sql = ' select * from Chuku '

2. Filter the specified field: List all fields to be displayed before from, if you want to skip using the "" "

' sql = ' select ' "'," "", "" "," "," "," "," ", spec, unit from Chuku"

3, Filter not duplicate: Distinct field name filter for records that are not duplicates

' sql = ' select Distinct ' "", Item code from Chuku

4, Filter by percentage: Top N percent can display the previous N records

' sql = ' select top Percent * chuku '

' The filtered fields are further processed and formatted with functions

' sql = ' Select Id,format (Out of date, "" Yyyy-mm-dd ") from Chuku"

5, Sort: desc Descending, ASC ascending

' sql = ' select * from Chuku ORDER by out date ASC, sales unit Price desc "
' sql =" SELECT top * to Chuku ORDER by out date ASC, sales ASP des C "' Filter the number of sales before 10 ()

Third, grouped display

Group by can be combined with functions to sum up, the group to find the maximum value and so on.

' sql = Select ' "", "" "" "," "" "" "" "", "" "" ", sum (out of stock) from Chuku Group by item code"

Display grouped records by condition

"sql = select" "" "" "" "", "" "" "," "" "" "" "", "" "", sum (out of stock) from Chuku Group by item code having sum (out of stock) >=3 "

The above is a small set to introduce the MySQL database of the Select Usage Summary, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.