Get the App
SLTechnology News&Howtos  ›  Database  › 

SQL basic grammar record

Shulou Source: shulou.com Published: 2022-06-01 15:22:39 10月01日 Update

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: =, >, =

Tags: Query name character data part grouping person function number name field student age mobile phone number operator operation grammar special underscore Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Apple Docker Linux macOS