Home > Database > SQL > Select statement in sql language

Select statement in sql language

Release: 2019-07-26 11:43:26
Original
11932 people have browsed it

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;
Copy after login

and:

SELECT * FROM table_name;
Copy after login

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
Copy after login

"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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template