Mysql 学习之路(二)Mysql基础知识之简单查询

1.查询单个字段

select last_name from employees;

2.查询多个字段

select last_name,salary,email from employees;

3.查询所有字段

select * from employees;

4.查询常量值

select 100;

select "john";

5.查询表达式

select 100*90;

6.查询函数;

select version();

7.字段起别名

select lase_name as “姓”,first_name as "名" from employees;

8.去重

select DISTINST department_id from employees;

9.字段连接

select CONCAT(last_name,first_name) as "姓名" from employees;

10.条件查询

select * from employees where salary>12000;

select last_name,department_id from employees where department_id != 90;

select last_name,department_id from employees where salary>10000 and salary<20000;

like:

  SELECT * FROM employees where last_name LIKE '%a%';(模糊查询,%包括任意多个字符,_为任意单个字符,\为转义符号)

  SELECT * FROM employees where last_name LIKE '__e%';

between and

  select * from employees where employee_id BETWEEN 100 and 120;

in

  select * from employees where job_id in ("IT_PROT","AD_VP","AD_PRES");

is null

  SELECT last_name commission_pct from employees where commission_pct  is  null;

  SELECT last_name commission_pct from employees where commission_pct  is not null;

安全等于

  SELECT last_name commission_pct from employees where commission_pct  <=> null;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值