--Query basic syntax Select Column name from table name where query condition
Select ClassName from Student s,class C where s.classid=c.id and Studentname= ' Zhang San '
--Fuzzy query is the first of 4: _ Represents a character
SELECT * from Student where studentname like ' _ Three '
--There are 4 second types of fuzzy queries:% represents a number of characters
SELECT * from Student where studentname like '% three '
--The second type of fuzzy query is 4: [] represents a character
SELECT * from Student where studentname like '%[2-5] '
--There are 4 second types of fuzzy queries: [^] denotes a character
SELECT * from Student where studentname like '%[^3, three] '
--Sort By default ascending ASC descending to desc ORDER by
SELECT * from Student ORDER by ClassId Asc,studentname desc
--group by group Count (*) The total number of queries is equivalent to where but after group by
-there can be a where when having a having
Select Classid,count (*) as number from Student where studentname!= ' Zhang San ' group by ClassId have ClassId =1
--max Max min Minimum count () Total avg average sum sum
SELECT * FROM Student
Select MAX (Id), studentname from Student Group by Studentname
Select Min (Id) from Student
Select Count (Id) from Student GROUP by Studentname
Select AVG (Id) from Student GROUP by Studentname
Select SUM (Id) from Student GROUP by Studentname
--INSERT statement
--insert into table name (column name) values (value)
INSERT into Student values (2, ' Harry ')
--Modify the statement
--update table Name set column name = ' value ', column name = ' value ' Where condition (if there is no where condition, the value of this column is changed)
Update Student set studentname= ' John Doe ', classid=4 where id=2
--delete delete from table if you want to delete data from the primary table, you need to remove the
--delete table name where condition is deleted according to condition, the self-increment column will not change after deletion
Delete Student where classid=4 and Studentname= ' John Doe '
Delete Student where classid=1
Delete Class where id=1
--Delete the entire table of data
TRUNCATE TABLE Student
TRUNCATE TABLE Class
SQL Server Base language