Quick Start for SQL language (i)

Source: Internet
Author: User
SQL language | QuickStart SQL is an abbreviation for the English Structured Query language, meaning Structured query language. The main function of SQL language is to establish and communicate with various databases. According to the ANSI (American National Standards Association), SQL is used as the standard language for relational database management systems. SQL statements can be used to perform a variety of operations, such as updating data in a database, extracting data from a database, and so on. Currently, most popular relational database management systems, such as Oracle, Sybase, Microsoft SQL Server, Access, and so on, all adopt the SQL language standard. Although many databases have been further developed and extended to SQL statements, standard SQL commands, including SELECT, Insert, Update, Delete, Create, and drop, can still be used to perform almost all database operations. Next, let's take a look at the basics of the SQL language.


Database tables

A typical relational database is usually composed of one or more objects called tables. All data or information in the database is saved in these database tables. Each table in the database has its own unique table name, which consists of rows and columns, each of which includes information such as the column name, data type, and other attributes of the column, and the row contains the records or data of a column. The following is an example of a database table called weather.

The highest temperature in the city is the lowest temperature
Beijing 10 5
Shanghai 15 8
Tianjin 8 2
Chongqing 20 13


The table "City", "Maximum temperature" and "minimum temperature" are three different columns, and each row in the table contains specific tabular data.


Data query

In many SQL commands, the SELECT statement should be the most frequently used. The SELECT statement is used primarily to query the database and return the result data that conforms to the user's query criteria. The syntax format for the SELECT statement is as follows:

Select Column1 [, Column2,etc] from TableName

[Where condition];

([] indicates an option)

The column names that are located after the Select keyword in the SELECT statement are used to determine which columns will be returned as the result of the query. Users can select any column they want, and you can use the wildcard "*" to set all the columns in the table.

The table name in the SELECT statement after the FROM keyword is used to determine the target table for the query operation.

The WHERE optional clause in the SELECT statement is used to specify which data values or which rows will be returned or displayed as query results.

You can use some of the following operators to set the query criteria in the WHERE condition clause:

= equals

> Greater than

< less than

>= is greater than or equal to

<= less than or equal

<> Not equal to

In addition to the operators mentioned above, the LIKE operator is also important in the WHERE conditional clause. The LIKE operator is very powerful, by using the LIKE operator, you can set only records that are the same as the user-specified format. In addition, we can use the wildcard character "%" to replace any string. Examples are as follows:

Select FirstName, LastName, City

From employee

where FirstName like ' E% ';

(Note that the string must be enclosed in parentheses)

The SQL statement above will query for all names beginning with E. Alternatively, use the following statement:

SELECT * FROM Employee

WHERE FirstName = ' may ';

Query for all rows with the name May.



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.