当前位置:Gxlcms > 数据库问题 > 数据库

数据库

时间:2021-07-01 10:21:17 帮助过:5人阅读

select id,name from student;

select id as ‘学号‘,name as ‘姓名‘ from student;(只是修改结果)

排序

select * from student where sex=‘1‘

order by sno asc,sname desc

ps:ASC正序排序;DESC逆序排序

IN、LIKE、IS NULL

select * from student 

where id IN(‘2020001‘,‘2020002‘,‘2020003‘)

where id NOT IN(‘2020001‘,‘2020002‘,‘2020003‘)

------------------------------------------------------------------

select * from student 

where phone IS NULL

select * from student 

where phone IS NOT NULL

------------------------------------------------------------------

select * from student where sname LIKE ‘张%‘

-----------------------------------------------------------------

ps:‘%’是通配符

常用函数

selece * from student where year(birthday)>=1980

and year(birthday)<1990

注:查询90后的信息

select max(id) from student

表的关联

SELECT stu.sname,stu.sage,stu.sno,sc.sno,sc.score
FROM student stu,score sc  //起别名
WHERE stu.sno=sc.sno  

 

数据库

标签:数据库   常用函数   name   strong   标签   排序   null   core   rom   

人气教程排行