An example of using select statement in sql
This article mainly introduces the use of sql select statement examples, with a certain reference value, interested friends can refer to, I hope you read this article after a lot of gains, the following let Xiaobian take you to understand.
SQL SELECT statement
SELECT statements are used to select data from a database.
The results are stored in a result table called the result set.
SQL SELECT syntax
SELECT column_name,column_nameFROM table_name;
and:
SELECT * FROM table_name;
Note: SQL statements are case-insensitive. SELECT is equivalent to select.
SQL SELECT instance
To get the contents of columns named "LastName" and "FirstName"(from a database table named "Persons"), use a SELECT statement like this:
SELECT LastName,FirstName FROM Persons
"Persons" table:
IdLastNameFirstNameAddressCity1AdamsJohnOxford StreetLondon2BushGeorgeFifth AvenueNew York3CarterThomasChangan StreetBeijing
Results:
LastNameFirstNameAdamsJohnBushGeorgeCarterThomas
SQL SELECT * Instance
Now we want to select all columns from the Persons table.
Replace column names with the symbol *, like this:
SELECT * FROM Persons
Tip: The asterisk (*) is a shortcut to select all columns.
Results:
IdLastNameFirstNameAddressCity1AdamsJohnOxford StreetLondon2BushGeorgeFifth AvenueNew York3CarterThomasChangan StreetBeijing
Navigating through the result-set
The results obtained by SQL queries are stored in a result set. Most database software systems allow you to navigate through the result set using programmatic functions such as Move-To-First-Record, Get-Record-Content, Move-To-Next-Record, and so on.
Thank you for reading this article carefully. I hope that Xiaobian's shared "SQL select statement use example" this article is helpful to everyone. At the same time, I hope that everyone will support it a lot. Pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!