MySQL的查询

232 阅读1分钟

基础查询

语法:

select 查询列表 from 表名;

特点 :

去重

select distince 关键词 from tables;

###取别名

select 关键词 as 别名 from tables; select keys 别名 from tables;

+号的使用

mysql中加号只能是运算符 如果说转换成功则加法 失败则失败方为0 null+int 表示只有一个为null结果就是null

select 10+90 ; #output 100
select “10”+90 ;# output 100
select “lkh” +90; # 90
select null+10;# (null)

因此要加俩字符串则需要利用函数 concat(‘a’,‘b’)

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