In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
SQL server in which commonly used sentences, many novices are not very clear, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
1. Simple query A simple Transact-SQL query only includes a select list, a FROM clause and a WHERE clause. They describe the column to be queried, the table or view of the query, and the search criteria, respectively. For example, the following statement queries the nickname and email fields in the testtable table with the name "Zhang San". SELECT nickname,emailFROM testtableWHERE name=' Zhang San'(1) the selection list (select_list) refers to the queried column, which can be composed of a list of column names, asterisks, expressions, variables (including local and global variables), and so on. 1. Select all columns for example, the following statement displays data for all columns in the testtable table: SELECT * column, select some columns and specify their display order the data in the query result set is arranged in the same order as the column names specified in the selection list. For example: SELECT nickname,emailFROM testtable3, change column headings in the select list, you can reassign column headings. Define the format as: column title = column name column title if the specified column title is not in the standard identifier format, quotation mark delimiters should be used, for example, the following statement uses Chinese characters to display the column title: SELECT nickname = nickname, email = emailFROM testtable4, delete duplicate rows in the SELECT statement use the ALL or DISTINCT option to display all eligible rows in the table or delete the duplicate data rows, the default is ALL. When using the DISTINCT option, only one row is left in the result set returned by SELECT for all duplicate rows of data. 5. Limit the number of rows returned. Use the TOP n [PERCENT] option to limit the number of rows returned. TOP n indicates that n rows are returned, while TOP n PERCENT indicates that n represents a score of 100 and specifies that the number of rows returned is equal to a few percent of the total number of rows. For example: SELECT TOP 2 * FROM testtableSELECT TOP 20 PERCENT * FROM testtable (II) the FROM clause FROM clause specifies the SELECT statement query and the table or view associated with the query. Up to 256 tables or views can be specified in the FROM clause, separated by commas. When the FROM clause specifies multiple tables or views at the same time, if a column with the same name exists in the selection list, you should use the object name to qualify the table or view to which these columns belong. For example, the cityid column exists in both the usertable and citytable tables When querying cityid in two tables, you should use the following statement format: SELECT username,citytable.cityidFROM usertable,citytableWHERE usertable.cityid=citytable.cityid can specify aliases for tables or views in the FROM clause in the following two formats: table names, as aliases, table aliases, for example, table aliases can be expressed in the form of table aliases such as the above statement: SELECT username,b.cityidFROM usertable acentCitytable bWHERE a.cityid=b.cityidSELECT can not only retrieve data from the table or view It can also query data from the set of results returned by other query statements. For example: SELECT a.au_fname+a.au_lnameFROM authors a title author ta (SELECT title_id,titleFROM titlesWHERE ytd_sales > 10000) AS tWHERE a.au_id=ta.au_idAND ta.title_id=t.title_id in this case, the result set returned by SELECT is given an alias t, and then data is retrieved from it. (3) use the WHERE clause to set the query condition WHERE clause to set the query condition and filter out the unnecessary data rows. For example, the following statement queries data older than 20: the SELECT * FROM usertableWHERE age > 20WHERE clause can include various conditional operators: comparison operator (size comparison): >, > =,
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.