Home >Database >SQL >Select statement in sql language

Select statement in sql language

尚
Original
2019-07-26 11:43:2611946browse

Select statement in sql language

SQL SELECT statement

The SELECT statement is used to select data from the database.

The results are stored in a result table, called a result set.

SQL SELECT syntax

SELECT column_name,column_name
FROM table_name;

and:

SELECT * FROM table_name;

Note: SQL statements are not case-sensitive. SELECT is equivalent to select.

SQL SELECT Example

To get the contents of the columns named "LastName" and "FirstName" (from the database table named "Persons"), please Use a SELECT statement like this:

SELECT LastName,FirstName FROM Persons

"Persons" table:

##IdLastNameFirstNameAddressCity1AdamsJohnOxford StreetLondon2BushGeorgeFifth AvenueNew York3CarterThomasChangan StreetBeijing
Result:

LastNameFirstNameAdamsJohnBushGeorge##Carter
Thomas
SQL SELECT * Example

Now we want to select all columns from the "Persons" table.

Please use the symbol * instead of column names, like this:

SELECT * FROM Persons

Tip: The asterisk (*) is a shortcut to select all columns.

Result:

##IdLastNameFirstName AddressCity1AdamsJohnOxford StreetLondon2BushGeorgeFifth AvenueNew York3CarterThomasChangan StreetBeijing

Navigating in the result-set

The results obtained by the SQL query program are stored in a result set. Most database software systems allow the use of programmatic functions to navigate within result sets, such as: Move-To-First-Record, Get-Record-Content, Move-To-Next-Record, and so on.

Recommended: "S

QL Video Tutorial

"

The above is the detailed content of Select statement in sql language. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn