Linux下mysql数据库的查询语句(一)

时间:2024-03-31 18:51:28

最简单的查询语句

select * from employee1(表名);
Linux下mysql数据库的查询语句(一)
这种查询可以查到表中的所有数据。
select name,salary,post from employee1;
Linux下mysql数据库的查询语句(一)
根据自己的需要查看有关的信息。还有去重语句distinct(select distinct post from employee1;)

通过四则运算查询

select name,salary14 from employee1;
Linux下mysql数据库的查询语句(一)
select name,salary
14 anut_salary from employee1;
(select name,salary*14 as anut_salary from employee1;)
Linux下mysql数据库的查询语句(一)

还可以定义显示的格式

concat() 函数用于连接字符串

Linux下mysql数据库的查询语句(一)

条件查询

1、单条件查询

Linux下mysql数据库的查询语句(一)

2、多条件查询

Linux下mysql数据库的查询语句(一)
关键字between and
Linux下mysql数据库的查询语句(一)
关键字is null
select name,salary,job_description from employee1 where job_description is null;
或者(select name,job_description FROM employee1 where job_description=’’;)
Linux下mysql数据库的查询语句(一)
关键字in
Linux下mysql数据库的查询语句(一)
Linux下mysql数据库的查询语句(一)
关键字like模糊查询
通配符%
Linux下mysql数据库的查询语句(一)
通配符’_’
Linux下mysql数据库的查询语句(一)