(13)like筛选出指定列的格式,%属于通配符。如y%匹配出以y开头的数据,反之,%y匹配出以y结尾的数据,%yu%就是匹配出中间含有yu字符的列表数据。NOT 关键字,您可以选取不匹配模式的记录。
select *from student where name like '%y';
select *from student where name like 'y%';
select *from student where name not like 'y%';
(14)通配符_代表替代一个字符,如匹配出nn与之有关的前后一个字符的数据
select *from student where name like'_nn_';
(15)用REGEXP 或 NOT REGEXP操作正则表达式。
如: 匹配出姓名以有ajuc开头的 select *from student where name REGEXP '^[ajuc]';
(16)从学生表中查找包含姓名为小王和jack和数据
IN 与 = 的异同
- 相同点:均在WHERE中使用作为筛选条件之一、均是等于的含义
- 不同点:IN可以规定多个值,等于规定一个值
select *from student where name in ('小王','jack');
select *from student where name='jack' or name='anny';
(17)between 用于取值。取二者之间的值 (反之NOT BETWEEN就是取不在此范围的数据)
如;从学生表中筛选出22到26之间的年龄的人
select *from student where sage between 22 and 26;
(18)用as实现列表别名
如把国家取个别名c
select country as c from student;
如:设置学生表的别名为s
select *from student as s;
(19)如何从a表中复制一列数据到b表。如:把学生表中的id这列复制到成绩s_id中。
insert into grade (s_id) select id from student;