Get the App
SLTechnology News&Howtos  ›  Database  › 

Principle and Design of Database system-- projection Operation and selection Operation

Shulou Source: shulou.com Published: 2022-06-01 10:01:06 10月03日 Update

Books: principles and Design of Database system (3rd Edition)-- edited by Liao Guoqiong et al.

Database version: SQL Server 2005

/ *

Select courseNO as course number, lower (coursename) course name, courseHour/16 as weekly class hours

From course

, /

/ *-the use of "% arbitrary characters", "_" wildcards

Select *

From class

Where className like'% accountant%'

Select studentNo,studentName

From Student

Where studentName like 'King _ _'

Select studentNo,studentName

From Student

Where studentName not like'% Fu%'

Select studentNo,studentName,nation

From Student

Where nation not like 'Mongolian'

Select studentNo,studentName,nation

From Student

Where nation like 'Mongolian'

, /

-- use of wildcards

/ *

Select className

From class

Where className like'% 'ESCAPE'\'

Union

Select className

From class

Where className like'\ _%'--No

Union

Select className

From class

Where className like'_% 'ESCAPE'\'--No

, /

For the use of escape characters, the following two methods are similar

/ *

Select className

From class

Where className like'# _% 'escape'

Select className

From class

Where className like'% 'ESCAPE'\'

, /

/ *-learn the logical operator or and

Select studentNo,courseNO,score

From score

Where courseNo='001' or courseNo='005' or courseNo='003'

Select studentNo,courseNO,score

From score

Where courseNo='001' and courseNo='003'

Select studentNo,courseNO,score

From score

Where courseNo in ('001', '005', '003')

, /

/ *

Select studentNO as student number, studentName as name, year (birthday) as year of birth

From Student

Where year (birthday) = 1998 and nation=' Han'

, /

/ *-if you are not born in Nanchang or Shanghai, choose one of the two implementation methods.

Select studentNO as student number, studentName as name, native

From Student

Where native not in ('Nanchang', 'Shanghai')

Select studentNO as student number, studentName as name, native

From Student

Where, Nanchang, and, Shanghai.

, /

/ * score in the 80m / m / m / 90 range

Select studentNo,courseNO,score

From score

Where score > = 80 and score

Tags: Shanghai Nanchang name student number method data database wrong character place of origin course wildcard Mongolian Mongolian principle system design operation similarity books Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Apple Xiaomi vpn MySQL