SQL quick start _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
SQL Quick Start 1. SQL is the abbreviation of StructuredQueryLanguage. it refers to the structured query language. The main function of SQL is to establish contact and communicate with various databases. ANSI stands for Structured Query Language, which is a Structured Query Language. The main function of SQL is to establish contact and communicate with various databases. According to ANSI (American National Standards Association), SQL is used as the standard language for relational database management systems. SQL statements can be used to perform various operations, such as updating data in the database and extracting data from the database. Currently, most popular relational database management systems, such as Oracle, Sybase, Microsoft SQL Server, and Access, use SQL language standards. Although many databases redevelop and expand SQL statements, they include Select, Insert, Update, Delete, Create, standard SQL commands, including Drop, can still be used to perform almost all database operations. Next, we will introduce the basic knowledge of the SQL language in detail.

Database tables
A typical relational database usually consists of one or more objects called tables. All data or information in the database is stored in these database tables. Each table in the database has its own unique table name, which is composed of rows and columns. each column contains the column name, data type, and other attributes of the column, the row contains the records or data of a column. The following is an example of a database table named weather.
Highest temperature and lowest temperature in the city
Beijing 10 5
Shanghai 15 8
Tianjin 8 2
Chongqing 20 13

In this table, "city", "maximum temperature" and "minimum temperature" are three different columns, and each row in the table contains specific table data.

Data Query
Among the many SQL commands, select statements are the most frequently used. The Select statement is mainly used to query databases and return results that meet the user's query criteria. The syntax format of the Select statement is as follows:
Select column1 [, column2, etc] from tablename
[Where condition];
([] Indicates the option)
The column name after the select keyword in the select statement is used to determine which columns will be returned as the query result. You can select any column as needed, and use the wildcard "*" to set all columns in the returned table.

The table name after the from keyword in the select statement is used to determine the target table to be queried.
The where clause in the Select statement specifies which data values or rows are returned or displayed as query results.
You can use the following operators to set the query criteria in the where clause:
= Equal
> Greater
<Less
> = Greater than or equal
<= Less than or equal
<> Not equal
In addition to the operators mentioned above, the LIKE operator is also very important in the where clause. The LIKE operator is very powerful. by using the LIKE operator, you can set to select only records in the same format as specified by the user. In addition, we can use the wildcard "%" to replace any string. Example:
Select firstname, lastname, city
From employee
Where firstname LIKE 'e % ';
(Note: the string must be included in the brackets)
The preceding SQL statement queries all names starting with "E. Alternatively, use the following statement:
Select * from employee
Where firstname = 'may ';
Query all rows named "May.

The abbreviation of structured Query Language. The main function of SQL is to establish contact and communicate with various databases. According to ANSI (United States...

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.