You can obtain an alias for the table and field during query. This alias can replace the specified table and field.
Alias for table
Copy codeThe Code is as follows:
Mysql> SELECT * FROM department d
-> WHERE d. d_id = 1001;
+ ------ + ----------- + -------------- + ------------- +
| D_id | d_name | function | address |
+ ------ + ----------- + -------------- + ------------- +
| 1001 | Ministry of Science and Technology | R & D product | layer 5, building 3 |
+ ------ + ----------- + -------------- + ------------- +
Row in set (0.00 sec)
Here, a specific department table named d is retrieved.
Alias for Field
Copy codeThe Code is as follows:
Mysql> SELECT d_id AS department_id, d_name AS department_name
-> FROM department;
+ --------------- + ----------------- +
| Department_id | department_name |
+ --------------- + ----------------- +
| 1001 | Ministry of Science and Technology |
| 1002 | Production Department |
| 1003 | sales department |
+ --------------- + ----------------- +
Rows in set (0.00 sec)
The syntax here is similar to the above except that the