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

Posted peterWXM

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;

以上是关于Mysql 学习之路Mysql基础知识之简单查询的主要内容,如果未能解决你的问题,请参考以下文章

mysql数据库学习目录

mysql数据库学习目录

快速开启MySQL数据库的学习之路

快速开启MySQL数据库的学习之路

快速开启MySQL数据库的学习之路

java数据库学习路线和必学知识点!