所以我有类似的请求
WITH customers_in_usa AS (
SELECT
customerName, state
FROM
customers
WHERE
country = 'USA'
) SELECT
customerName
FROM
customers_in_usa
WHERE
state = 'CA'
ORDER BY customerName;
但是在编写它时我发现了一个错误:“WITH 在这个位置上的输入无效”error_picture。你能帮我理解这段代码有什么问题吗?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
WITHcustomers_in_usaAS目前是无效的 MySQL 代码。 MySQL 将来将在 MySQL 版本 8 中支持 CTE。您可以重写 SQL 代码,这应该会产生相同的结果。
SELECT customerName , state FROM customers WHERE country = 'USA' AND state = 'CA' ORDER BY customerName