SQL Server Basics Tutorial: Select Learning

Source: Internet
Author: User
Keywords Network programming MSSQL tutorials
Tags basics data delete join learning name network network programming
1.SELECT statement Select data from the database

Select ' Column name ' from ' Table name ' SELECT List_name from table_name the ' table name ' Selection ' column name ' data SQL SELECT * FROM table_name ' all data from ' table name ' selection

2.SELECT Add where statement

SELECT ' column name ' from ' Table name ' WHERE ' condition '

3.SELECT Plus as statement

Specify an alias to the data using as. This alias is used to use the count () function in an expression to calculate the number of elements in an array or the number of attributes in an object. SELECT CONCAT (*) as New_name

4.SELECT JOIN ON statement

Join Joint Operation two table select ' Column name 1 ' column Name 2 ' from ' Table name 1 ' JOIN ' table name 2 ' on condition select A.symbol,a.sname from Securitycode a JOIN dayquote B on a. Full usage of SYMBOL =b.symbol sql--join (version 2)

5.SELECT ORDER BY statement

Order by sort ASC Ascending, DESC descending select ' column name ' from ' Table name 1 ' ORDER by ' column name ' [ASC, DESC] Select List_name from table_name Orders by List_ Name

6.SELECT Limit Statement

SELECT * FROM table LIMIT [offset,] rows | Rows Offset offset LIMIT Returns the specified number of records. LIMIT accepts one or two numeric parameters. parameter must be an integer constant. Given two parameters, the first parameter specifies the offset of the first row to return the record, and the second parameter specifies the maximum number of rows to be returned. The offset of the initial record line is 0 (instead of 1): SELECT * FROM table LIMIT 5, 10; Retrieve record line 6-15//To retrieve all row rows from an offset to the end of the recordset, you can specify that the second parameter is -1:select * from table LIMIT 95,-1; Retrieves the record row 96-last. If only one argument is given, it represents the maximum number of record rows returned: SELECT * from table LIMIT 5; Retrieves the first 5 rows//In other words, LIMIT n is equivalent to LIMIT 0,n.

Learn the SQL Insert Intoupdatedelete action statement with everyone:

1.INSERT into

Insert into table name values (value 1, value 2,....) inserts a value of 1, value 2, into the table name (column 1, column 2,...) by inserting a row of values in the table name. Values (value 1, value 2,....) specify column insertion data

2.UPDATE

UPDATE table Name set column name = ' value 2 ' where column name = ' value 1 ' Sets the original column value to value 1 in the table to the value 2

2.DELETE

Delete from table name where column = ' value 1 ' delete Column Name value 1 row delete from table name where column = ' value 1 ' delete * FROM table name delete from table name remove all rows of table name

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.