一、查看其它库的所有表 语法:show tables from 库名;
二、查看当前数据下有哪些数据表 语法:show tables
三、分类:
(1)、按条件表达式筛选:
条件运算符:>、<、=、!=、<>、>=、<=、
(2)、按逻辑表达式筛选:
逻辑运算符:&&、||、!、and、or、not、
示例:查询工资在10000到20000之间的员工名、工资以及资金
select last_name,salary,commission_pct from employees where salary>=10000 and salary<=20000
(3)、模糊查询
like、between and、in、is null/is not null
示例:查询员工名中包含字符a的员工信息
select * from employees where last_name like’%a%’
注意:
like 特点:一般和通配符搭配使用
通配符:% 任意多个字符,包含0个字符
_任意单个字符
查询
特点:1、查询列表可以是表中的字段、常量值、表达式、函数
2、查询的结果是一个虚拟的表格
(1)、简单查询 语法: select 字段名1,字段名2,字段名3 from 表名;
(2)、select * from 表名; * 号代表所有字段,我们不推荐使用*
(3)、查询某一条信息,我们要用where进行过滤
示例: select * from studentinfo where stuId=‘10’
(4)、查询的时候可以给字段起别名
语法: as 别名
示例:select stuId as 学号,stuName as 姓名,gender as 性别,age as 年龄 from studentinfo;
特点:便于理解;如果查询的字段有重名的情况,使用别名。