Basic mysql operations-removing duplicates, taking field names, query expressions, constants, etc., and the + sign
query constant value
SELECT 100; #Display constant values SELECT 'bitch';#Display string constants in single quotes
query expression
SELECT 100*99;SELECT 100%99;
query function
SELECT VERSION();
alias a field
SELECT 100*99 AS results; #Name the field as result, single quotation marks may be added, SELECT last_name AS last name,first_name AS name FROM employees may not be added; #Name multiple fields SELECT last_name AS last name FROM employees; #Method 2: Write field name SELECT last_name AS "out put" FROM employees directly without AS; #When field name contains keywords and special symbols, single/double quotation marks may be added
deduplication
Case: Query all department numbers involved in the employee table, remove the same number, add distinct
SELECT DISTINCT department_id FROM employees;
The + sign:
Only operator function, does not have string concatenation, when there is a string, it will convert the character type to the numerical type.
#As long as one side is null, the addition result must be null
SELECT NULL+10;
Case study: Employee first name and last name concatenated into one field and displayed as name
SELECT last_name+first_name AS Last name FROM employees;