gpt4 book ai didi

mysql - 错误 #1241 SQL 查询

转载 作者:可可西里 更新时间:2023-11-01 07:57:56 25 4
gpt4 key购买 nike

我不断收到错误代码 #1241。我一直在寻找答案,但找不到对我有帮助的答案。

这是我的代码:

SELECT name, address, city, phone  
FROM customer
WHERE customer.ID IN (
SELECT customer.ID, COUNT(*) AS amount_reservations
FROM customer, (
SELECT ID
FROM customer, reservations
WHERE rent_time = 'weekend' AND
ID = customer_ID
) AS foo
WHERE customer.ID = foo.ID
GROUP BY customer.ID
HAVING amount_reservations > 1
)

最佳答案

子查询 SELECT customer.ID, COUNT(*) AS amount_reservations 应该有一个列,而不是两个。

将其更改为:

SELECT name, address, city, phone  
FROM customer
WHERE customer.ID IN (
SELECT customer.ID
FROM customer, (
SELECT ID FROM customer, reservations
WHERE rent_time = 'weekend' AND ID = customer_ID
) AS foo
WHERE customer.ID = foo.ID
GROUP BY customer.ID HAVING count(*) > 1
)

关于mysql - 错误 #1241 SQL 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50803416/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com