Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SQL basic grammar record

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Basic syntax of SQL

1:select sno,sname from student where sage between 20 and 30-find out people between 20 and 30 years old

2:select sno,sname from student where sage is null-query empty age persons from the student table

3:select sno,sname from student where sname= "cary" or sname= "mina" or sname "amy"-query the student number and name of cary,mina,amy

You can also use select sno,sname from student where sname in ('cary','mina','amy') to achieve the same function

Select part

1:AS can rename fields

2:distinct deduplicates values

3: aggregate function () avg (), max (), min (), sum (), count ()

4:TOP 5 first 5 rows of data select top 5 sno,sname from student

The 5:Into select top 5 into testtable from student stores the queried TOP 5 data in the testtable table, which exists in the

In the table in the master database

Select sno,sname,sage,sex into test table02 from student where 11-get student table structure

From part

1: table rename

Select bookname from book as T1 as T2 where t1.id=t2.id-rename T1 borrowbook to T2 for the book table

2: combine subquery

Select distinct bookname from book as T1, (select distinct bookid from borrowbook) as T2 where t1.bookid=t2.bookid

Where part

1: number: =, >, =

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report