首页 > 其他分享 >select查询语句

select查询语句

时间:2023-02-25 19:01:48浏览次数:38  
标签:语句 DISTINCT employees 查询 select department 写法 id SELECT

显示表结构(DESCRIBE/DESC)

DESCRIBE employees;
DESC employees;

 

列的别名(AS)

SELECT employee_id emp_id FROM employees; #省略写法
SELECT employee_id AS emp_id FROM employees; #AS未省略写法
SELECT employee_id "emp_id" FROM employees; #""双引号写法,适用于别名有空格的

 

去重(DISTINCT)  

SELECT DISTINCT department_id FROM employees; #正确写法
SELECT salary,DISTINCT department_id FROM employees; #错误写法
SELECT DISTINCT salary,department_id FROM employees; #正确写法(同时满足salary,department_id) 

 

查询常数:

SELECT '测试',123,employee_id,last_name FROM employees;

 

标签:语句,DISTINCT,employees,查询,select,department,写法,id,SELECT
From: https://www.cnblogs.com/hhs1998/p/17155064.html

相关文章