In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use SELECT and SELECT* sentences in SQL, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
SQL SELECT statement
The SELECT statement is used to select data from a table, and the results are stored in a result table (called a result set). Syntax:
SELECT column name FROM table name SELECT * FROM table name
Note: SQL statements are not case-sensitive. SELECT is equivalent to select.
SQL SELECT instance
To get the contents of columns named "LastName" and "FirstName", use SELECT statements like this:
SELECT LastName,FirstName FROM Persons
"Persons" table:
Id LastName FirstName Address City1 Adams John Oxford Street London2 Bush George Fifth Avenue New York3 Carter Thomas Changan Street Beijing
Result table (result set):
LastName FirstNameAdams JohnBush GeorgeCarter Thomas
SQL SELECT * instance
Now we want to select all the columns from the "Persons" table. Replace the column name with the symbol *, like this:
SELECT * FROM Persons
Result table (result set):
Id LastName FirstName Address City1 Adams John Oxford Street London2 Bush George Fifth Avenue New York3 Carter Thomas Changan Street Beijing
Tip: an asterisk (*) is a shortcut to select all columns.
SQL SELECT DISTINCT statement
Duplicate values may be included in the table, and sometimes you may want to list only different (distinct) values.
The keyword DISTINCT is used to return a unique different value. The syntax is as follows:
SELECT DISTINCT column name FROM table name
Use the DISTINCT keyword
To select only a unique different value from the Company column, we need to use the SELECT DISTINCT statement:
SELECT DISTINCT Company FROM Orders
"Orders" table:
Company OrderNumberIBM 3532HuluMiao 2356Apple 4698IBM 6953
Results:
CompanyIBMHuluMiaoApple
Note: "IBM" is listed only once in the result set. If you use the SELECT statement directly, it will be listed twice.
Thank you for reading this article carefully. I hope the article "how to use SELECT and SELECT* sentences in SQL" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.