Products表含有字段prod_name代表產(chǎn)品名稱 prod_name flower rice ring umbrella Customers表代表顧客信息,cust_name代表顧客名稱 cust_name andy ben tony tom an lee hex 【問題】 編寫 SQL 語句,組合 Products 表中的產(chǎn)品名稱(prod_name)和 Customers 表中的顧客名稱(cust_name)并返回,然后按產(chǎn)品名稱對結果進行升序排序。 【示例結果】 prod_name an andy ben flower hex lee rice ring tom tony umbrella 【示例解析】 拼接cust_name和prod_name并根據(jù)結果升序排序
示例1
輸入
DROP TABLE IF EXISTS `Products`;
CREATE TABLE IF NOT EXISTS `Products` (
`prod_name` VARCHAR(255) NOT NULL COMMENT '產(chǎn)品名稱'
);
INSERT INTO `Products` VALUES ('flower'),
('rice'),
('ring'),
('umbrella');
DROP TABLE IF EXISTS `Customers`;
CREATE TABLE IF NOT EXISTS `Customers`(
cust_name VARCHAR(255) NOT NULL COMMENT '客戶姓名'
);
INSERT `Customers` VALUES ('andy'),('ben'),('tony'),('tom'),('an'),('lee'),('hex');
輸出
an
andy
ben
flower
hex
lee
rice
ring
tom
tony
umbrella
加載中...