列表

详情


SQL74. 纠错2

描述

供应商表Vendors有字段供应商名称vend_name、供应商国家vend_country、供应商省份vend_state
vend_name vend_country vend_state
apple USA CA
vivo CNA shenzhen
huawei CNA xian
【问题】修改正确下面sql,使之正确返回
SELECT vend_name 
FROM Vendors 
ORDER BY vend_name 
WHERE vend_country = 'USA' AND vend_state = 'CA';
【示例结果】
结果返回vend_name
vend_name
apple

示例1

输入:

DROP TABLE IF EXISTS `Vendors`;
CREATE TABLE IF NOT EXISTS `Vendors` (
  `vend_name` VARCHAR(255) NOT NULL COMMENT 'vend名称',
  `vend_country` VARCHAR(255) NOT NULL COMMENT 'vend国家',
  `vend_state` VARCHAR(255) NOT NULL COMMENT 'vend州'
);
INSERT INTO `Vendors` VALUES ('apple','USA','CA'),
('beef noodle king','USA','CA'),
('vivo','CNA','shenzhen'),
('huawei','CNA','xian');

输出:

apple
beef noodle king

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

Mysql 解法, 执行用时: 39ms, 内存消耗: 6480KB, 提交时间: 2022-03-07

SELECT vend_name 
FROM Vendors 
WHERE vend_country = 'USA' AND vend_state = 'CA'
ORDER BY vend_name;

Mysql 解法, 执行用时: 39ms, 内存消耗: 6512KB, 提交时间: 2022-03-04

SELECT 
    vend_name 
FROM Vendors 

WHERE vend_country = 'USA' AND vend_state = 'CA'

ORDER BY vend_name 

Mysql 解法, 执行用时: 39ms, 内存消耗: 6644KB, 提交时间: 2022-03-04

select 
vend_name
from Vendors
where vend_country="USA" and vend_state="CA"
order by vend_name;

Mysql 解法, 执行用时: 40ms, 内存消耗: 6392KB, 提交时间: 2022-06-04

SELECT vend_name 
FROM Vendors 
WHERE vend_country = 'USA' AND vend_state = 'CA'
ORDER BY vend_name ;

Mysql 解法, 执行用时: 40ms, 内存消耗: 6432KB, 提交时间: 2022-06-04

SELECT vend_name 
FROM Vendors 

WHERE vend_country = 'USA' AND vend_state = 'CA' ORDER BY vend_name