MySQL result set data query (FOCUS)

Source: Internet
Author: User

As follows:

SELECT *  fromProduct--Querying all ColumnsSELECTPro_id,pro_name fromProduct--querying a specified columnSELECTPro_name as 'Product Name', Price fromProduct--Add constant column change pro_id to "Product name" (Add constant column just show this name, query or original) and querySELECTpro_id, (Protype+Price as'Total Price'  fromProduct--Merge Columns Protype+price two columns when querying add a constant column Note: Merge columns can only merge fields of numeric typesSELECT DISTINCTProtype fromProduct--Remove duplicate columns when queryingSELECT *  fromProductWHEREPinpai='Sony' andChandi='Shenzhen';--conditional Query and (and) or (or)SELECT *  fromProductWHEREProtype>1;--Compare Queries > < >= <= = <> (not equal)SELECT *  fromProductWHEREProtypebetween 1  and 2;--query Protype between 1 and 2 (equivalent to >=1 and <=2)SELECT *  fromProductWHEREProtype>=1  andProtype<=2;--the difference between null and ' (empty string)--null with IS null/is not nul--empty string with = '/<> 'SELECT *  fromProductWHEREProtype is NULL;--query protype is nullSELECT *  fromProductWHEREProtype is  not NULL;--query Protype not mull.SELECT *  fromProductWHEREProtype= "';--query Protype is an empty stringSELECT *  fromProductWHEREProtype<> "';--Query Protype is not an empty string--query that product is not emptySELECT *  fromProductWHEREProtype is  not NULL  andProtype<> "';--find products with Sony in all products--%: denotes any character--_: Represents a characterSELECT *  fromProductWHEREPro_name like '% sony%';--inquire about total sales of ProtypeSELECT SUM(Protype) fromproduct;--Query the maximum value of Protype salesSELECT MAX(Protype) fromproduct;--minimum value for query Protype salesSELECT MIN(Protype) fromproduct;--find the average of sales for ProtypeSELECT AVG(Protype) fromproduct;--There are several products that query product--Note: The count () function counts the number of data that does not contain null--Use count statistics for the number of records to use fields that do not contain null valuesSELECT COUNT(*) fromProduct

MySQL result set data query (FOCUS)

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.