sqlserver--Data Retrieval (query)

Source: Internet
Author: User

Use MyDataBase1

--* Indicates that all columns are displayed

--The query statement does not add a where condition to indicate that all rows are queried

Select *from tblstudent

---Query only some of the columns in the table

Select Tsid,tsname,tsgender from Tblstudent

---query only part of the row (using the Where condition to filter a portion of the row display), depending on the condition

SELECT * FROM Tblstudent where tsclassid=5

--Aliases for columns in the query result set

Select TSID as student number, tsname as student name, Tsgender as gender from Tblstudent

--can also be arranged in this way

Select

TSID as student number,

Tsname as student name,

Tsgender as Sex

From Tblstudent

Select

TSID ' (student number) ',--can output spaces

Tsname student Name,--Cannot output space

Tsgender Sex

From Tblstudent

Select

Student number =tsid,

Student name =tsname,

Sex =tsgender

From Tblstudent

Select

Student number =tsid,

Student name =tsname,

Sex =tsgender,

Marriage no = ' no '

From Tblstudent

--Not that select must be used in conjunction with from, you can use select alone

Select

Current system time =getdate ()

Select

Monitor = ' Yan Meng ',

Class flower = ' TBD ',

Ban Cao = ' TBD ',

Teacher in charge = ' song ci '

--distinct keyword, for results that have been queried and then remove duplicates

SELECT DISTINCT * from Tblstudent

Select distinct tsname,tsgender,tsaddress from tblstudent

sqlserver--Data Retrieval (query)

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.