32. 將employees表的所有員工的last_name和first_name拼接起來作為Name
阿新 • • 發佈:2018-11-08
題目描述
將employees表的所有員工的last_name和first_name拼接起來作為Name,中間以一個空格區分
CREATE TABLE `employees` ( `emp_no` int(11) NOT NULL,
`birth_date` date NOT NULL,
`first_name` varchar(14) NOT NULL,
`last_name` varchar(16) NOT NULL,
`gender` char(1) NOT NULL,
`hire_date` date NOT NULL,
PRIMARY KEY (`emp_no`));
輸入描述:
無
輸出描述:
Name |
---|
Facello Georgi |
Simmel Bezalel |
Bamford Parto |
Koblick Chirstian |
Maliniak Kyoichi |
Preusig Anneke |
Zielinski Tzvetan |
Kalloufi Saniya |
Peac Sumant |
Piveteau Duangkaew |
Sluis Mary |
1. SQLLite使用||進行字串的拼接:
SELECT
last_name || " " || first_name AS NAME
FROM
employees;
2. MySQL使用CONCAT或者CONCAT_WS兩種函式進行字串的拼接:
https://blog.csdn.net/qq_34436819/article/details/81154028
https://blog.csdn.net/qq_15783243/article/details/73234372
SELECT
concat_ws(
space(1),
last_name,
first_name
) AS NAME
FROM
employees;