Tips on MySQLSELECT statements

Source: Internet
Author: User
The following articles mainly describe how to quickly master the actual operation steps of the MySQLSELECT statement, and what precautions should we pay attention to when learning the MySQLSELECT statement? The following describes the main content of the article. How to install and operate a MySQL database (the best combination with PHP)

The following articles mainly describe how to quickly master the actual operation steps of MySQL SELECT statements, and what precautions should we pay attention to when learning MySQL SELECT statements? The following describes the main content of the article. How to install and operate a MySQL database (the best combination with PHP)

The following articles mainly describe how to quickly master the actual operation steps of MySQL SELECT statements, and what precautions should we pay attention to when learning MySQL SELECT statements? The following describes the main content of the article.

How to install and operate a MySQL database (the best combination with PHP)

How to back up and restore a MySQL database (the best combination with PHP)

VC Implementation and Application of MySQL (best combination with PHP) database interface (2)

How to back up a MySQL database (the best combination with PHP)

MySQL (the best combination with PHP): use Java to test the best combination of MySQL (and PHP) Databases

MySQL (best combination with PHP) database technology (01)

How to connect to MySQL (the best combination with PHP) database in ASP

The easiest way to back up a MySQL database (the best combination with PHP)

MySQL (best combination with PHP) database backup and recovery

MySQL (the best combination with PHP) has too many database connections.

This article provides a quick and detailed understanding of MySQL SELECT statements in MySQL (the best combination with PHP) databases.

The basic syntax of the SELECT statement in MySQL (the best combination with PHP) is:

The following is a reference clip:

 
 
  1. SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT]
  2. [SQL_BIG_RESULT] [HIGH_PRIORITY]
  3. [DISTINCT|DISTINCTROW|ALL]
  4. select_list
  5. [INTO {OUTFILE|DUMPFILE} 'file_name' export_options]
  6. [FROM table_references [WHERE where_definition]
  7. [GROUP BY col_name,...] [HAVING where_definition]
  8. [ORDER BY {unsighed_integer|col_name|formura} [ASC|DESC],...]
  9. [LIMIT [offset,] rows] [PROCEDURE procedure_name]]

From this basic syntax, we can see that the simplest MySQL SELECT statement is SELECT select_list. In fact, you can use this simplest SELECT statement to complete many functions you want, first, you can use it to perform any operation supported by MySQL (the best combination with PHP). For example: SELECT 1 + 1, it returns 2. Second, you can also use it to assign values to variables. in PHP, using the SELECT statement function, you can freely use MySQL (the best combination with PHP) and assign values to variables. In many cases, you will find that MySQL (the best combination with PHP) has many more powerful functions than PHP.

STRAIGHT_JOIN, SQL _SMALL_RESULT, SQL _BIG_RESULT, and HIGH_PRIORITY are extensions of ANSI SQL92 in MySQL (the best combination with PHP. If the optimizer joins tables in a non-optimal order, use STRAIGHT_JOIN to speed up the query.

SQL _SMALL_RESULT and SQL _BIG_RESULT are a set of relative keywords. They must be used with group by, DISTINCT, or DISTINCTROW. SQL _SMALL_RESULT tells the optimizer that the result will be very small. MySQL (the best combination with PHP) is required to use a temporary table to store the final table instead of using the sorting. Otherwise, SQL _BIG_RESULT tells the optimizer that the result will be very small, mySQL (the best combination with PHP) is required to use sorting instead of temporary tables.

HIGH_PRIORITY will give MySQL SELECT a higher priority than a statement for updating a table, so that it can perform a quick query with priority.

The usage of the above four keywords is indeed obscure. Fortunately, in most cases, we can choose not to use these four keywords in MySQL (the best combination with PHP.

DISTINCT and DISTINCTROW provide a basic but useful filter for the returned result set. That is, only non-duplicate rows are included in the result set. Note that for keywords DISTINCT and DISTINCTROW, NULL values are equal, no matter how many NULL values there are, select only one. The use of "ALL" is too confusing. It has no effect on the generation of result sets.

INTO {OUTFILE | DUMPFILE} 'file _ name' export_options to write the result set to a file. Files are created on the server host and cannot exist. The syntax in the export_options section of the statement is the same as that in the FIELDS and LINES clauses used in the load datainfile statement. We will use MySQL (the best combination with PHP) in the advanced _ load data section, we will discuss it in detail. The keyword difference between OUTFILE and DUMPFILE is that only one row is written to the file before, and no column or row ends.

The above content is an introduction to the quick understanding of the MySQL SELECT statement.

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.