Mysql > select * from table_name; Mysql > select * from table_name; The result set of the query is a virtual table, which does not exist. The query list supports constants, fields (columns), expressions, methods (functions), and so on. Database () version() user() ifnull() concat()
USE myemployees; SELECT 100; SELECT 'liu Baoying' from 'SELECT '; # characters and strings are called character types in SQL. Constant values need to be enclosed in single quotes! SELECT 100*3; SELECT 100%3; SELECT last_name FROM employees; SELECT last_name,hiredate,salary FROM employees; SELECT 'employee_id', 'first_name', 'last_name', 'email', 'phone_number', 'job_id', 'salary', 'job_id', 'last_name', 'email', 'phone_number', 'job_id', 'salary', `commission_pct`, `manager_id`, `department_id`, `hiredate` FROM employees ; SELECT * FROM employees; SELECT DATABASE(); SELECT VERSION(); SELECT USER(); SELECT DISTINCT department_id FROM employees SELECT DISTINCT department_id FROM employees; SQL + select 100+2.5; SQL + select 100+2.5; SQL + select 100+2.5; B, number + character: select 100+' ABC '; +null: select 100+null; SELECT first_name+last_name FROM employees; SELECT last_name FROM employees; SELECT CONCAT(first_name,last_name) FROM employees; #⑨ alias /* The alias usually does not need to use quotation marks, but if it contains special characters such as Spaces. As SELECT CONCAT(first_name,last_name) as' last_name 'FROM employees; SELECT CONCAT(first_name,last_name) 'last_name' FROM employees; Alter table DESC employees; SELECT last_name, job_id, salary AS sal FROM employees; SELECT last_name, job_id, salary AS sal FROM employees; SELECT * FROM employees; SELECT employee_id, last_name, salary * 12 "ANNUAL salary "FROM employees; #4. Display the structure of table DEPARTMENTS and query all of its data against DESC departments; SELECT * FROM departments; SELECT * FROM employees; SELECT * FROM employees; SELECT * FROM employees; #6. Display all columns of the table employees, separated by commas, The column header displays as OUT_PUT SELECT CONCAT(last_name,first_name,salary,email,phone_number,IFNULL(commission_PCt,0)) OUT_PUT FROM employees; SELECT IFNULL(commission_pct,0),commission_pct FROM employees;Copy the code