操作数据库---查select --distinct --where --between

2022/4/4 19:20:47

本文主要是介绍操作数据库---查select --distinct --where --between,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

查询

-- 别名,给结果起个别名  as  可以给字段起别名,也可以给表起别名
select `studentNO` as学号,`studentName` as学生姓名 from stdent as s;

-- 函数concat(a,b) 
select concat(`姓名`,studentName) as 新名字 from student;

select version() -- 查询系统版本(函数)
select 100*3-1 as 计算结果   -- 用来计算(表达式)
select @@auto_increment_increment  -- 查询自增的步长(变量)

select distinct `studentNO` from result  -- 数据重复,去重
select `studentNO`,`studentResult`+1 as'提分后' from result  -- 学员考试成绩+1分查看

-- 查询成绩在95-100之间
select studentNO,studentResult from result where studentResult>=95 and studentResult<=100;
select studentNO,studentResult from result where studentResult between 95 and 100;  --模糊查询

逻辑运算符

运算符 语法 描述
and && a and b a&&B 逻辑与,2个都为真,结果才为真
or || a or b a||b 逻辑或,其中一个为真,就为真
not ! not a !a 逻辑非,真为假,假为真


这篇关于操作数据库---查select --distinct --where --between的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程