1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #查看数据 select * from "表名";
#查看十年后的年龄 select uname,age+10 from stu;
#给字段起别名 select uname,age+10 as 00xx from stu; select uname,age+10 00xx from stu;
#连接字段合并输出 select uname,concat(sex,'===',age) from stu;
#between 15 and 20; 介于15到20之间 select * from stu where age between 15 and 20 && sex='女';
#not between 20 and 30; 不介于20到30之间 select * from stu where age not between 20 and 30 && sex='女';
#in (2,7,34,49,81);在2,7,34,49,81中 select * from stu where uid in (2,7,34,49,81);
#not in(20-30);不介于20到30之间 select * from stu where age not in(20-30) && sex='女';
#查询姓孙的人,%代表任意字符 select * from stu where uname like '孙%';
#查询名称为两个字的人,_代表一个字符 select * from stu where uname like '__';
|