mysql_简单查询

1.避免重复

# 查询employee表下的post字段,不显示重复记录。
SELECT DISTINCT post FROM employee;

2.四则运算

# 查询employee表中name字段和并将salary字段中的数值乘12显示。
select name,salary*12 from employee;
# 查询employee表中name字段和并将salary字段中的数值乘12显示字段名为annual_salary。
select name,salary*12 as annual_salary from employee;

3.定义显示格式

# 将查询到的内容按定义的显示格式打印。
select concat('姓名:',name,'薪资:',salary) from employee;

# 将查询到的记录用指定的符号分割显示,表的标题设置为wdc。
select concat_ws('',name,sex,age,salary) as wdc from employee;

原文地址:https://www.cnblogs.com/wangdianchao/p/12256923.html