9.2.1查询所有的列
*表示所有列
##查询所有的员工信息
Select * from emp;
9.2.2查询指定列
输入特指表里的单独列名进行查询
Select empno,ename,depton from emp;
9.3条件查询where
9.3.1常见的运算符
关系运算符:=、!=、<>、>=、<=
区间:between A and B -》[A,B]
And:并且,和
Or:或者
Not:否,非
Is Not null:非空
In:在什么里面
9.3.2查询年龄为65的女学生(where,and)
Select * from stu where age='65' and gender='female';
+--------+-------+------+--------+
| sid | sname | age | gender |
+--------+-------+------+--------+
| S_1004 | liSi | 65 | female |
+--------+-------+------+--------+
9.3.3查询学号为S_1001或名字为lisi的记录(where,or)
Select * from stu where sid='S_1001'or sname='lisi';
+--------+-------+------+--------+
| sid | sname | age | gender |
+--------+-------+------+--------+
| S_1001 | liuYi | 35 | male |
| S_1004 | liSi | 65 | female |
+--------+-------+------+--------+
9.3.4查询学号是S_1001,S_1002,S_1003的记录(where,in)
写法一:select * from stu where sid = 'S_1001' or sid = 'S_1002' or sid = 'S_1003';
写法二:select * from stu where sid in('S_1001','S_1002','S_1003');
+--------+----------+------+--------+
| sid | sname | age | gender |
+--------+----------+------+--------+
| S_1001 | liuYi | 35 | male |
| S_1002 | chenEr | 15 | female |
| S_1003 | zhangSan | 95 | male |
+--------+----------+------+--------+
9.3.5查询学号不是S_1001,S_1002,S_1003的记录(where,not,in)
select * from stu where sid not in('S_1001','S_1002','S_1003');
9.3.6查询年龄为null的记录(where)
Select * from stu weher age is null;
9.3.7查询年龄在20-40之间的记录(between)
方式一:Select * from stu where age >=20 and <=40;
方式二:Select * from stu where age between 20 and 40;
9.3.8查询性别为非男的记录(where,not)
方式一:Select * from stu where gender !='male'
方式二:Select * from stu where not gender ='male'
方式三:Select * from stu where gender <> 'male'
9.3.9查询名字不为空的学生信息(is not null)
Select * from stu where sname is not null;
原文转载:http://www.shaoqun.com/a/697733.html
marks spencer:https://www.ikjzd.com/w/2385
easy buy:https://www.ikjzd.com/w/2162
9.2.1查询所有的列*表示所有列##查询所有的员工信息Select*fromemp;9.2.2查询指定列输入特指表里的单独列名进行查询Selectempno,ename,deptonfromemp;9.3条件查询where9.3.1常见的运算符关系运算符:=、!=、<>、>=、<=区间:betweenAandB-》[A,B]And:并且,和Or:或者Not:否,非IsNo
数魔跨境:https://www.ikjzd.com/w/1425.html
review:https://www.ikjzd.com/w/2735
gem:https://www.ikjzd.com/w/1997
手机三脚架卖爆亚马逊,销量增10倍!短视频神器TikTok功不可没:https://www.ikjzd.com/home/108048
全球开店卖家转型咨询:https://www.ikjzd.com/w/1298
Yahoo终于死了!"阿里他爸"走向末路……:https://www.ikjzd.com/home/21221
No comments:
Post a Comment