gpt4 book ai didi

mysql - 复杂 MySQL 子查询的语法错误

转载 作者:行者123 更新时间:2023-11-29 21:24:56 25 4
gpt4 key购买 nike

我看不出这里的问题,除非我根本不理解MySQL中的子查询。我得到了一个包含大量 LEFT JOIN 的缓慢查询,因此我尝试将这些 JOIN 重写为子查询。我是这样开始的:

  select t.title AS title,
(select
group_concat(distinct haha_supplier.display_name order by haha_supplier.display_name ASC separator ', ') AS contributors
from haha_supplier where haha_supplier.supplier_id IN
(select haha_title_to_supplier.supplier_id from haha_title_to_supplier where haha_title_to_supplier.title_id = t.title_id))
AS contributors,
(select haha_supplier.supplier_id
from haha_supplier where
where haha_supplier.supplier_id IN
(select haha_title_to_supplier.supplier_id from haha_title_to_supplier where haha_title_to_supplier.title_id = t.title_id))
AS supplier_id,
(select haha_supplier.group_letter
from haha_supplier where
where haha_supplier.supplier_id IN
(select haha_title_to_supplier.supplier_id from haha_title_to_supplier where haha_title_to_supplier.title_id = t.title_id))
AS group_letter,
select
group_concat(distinct concat(user.first_name,' ',user.last_name) separator ', ') as marketer
from user where user.id IN
(select wawa_suppliers_to_haha_marketing_contacts.user_id from wawa_suppliers_to_haha_marketing_contacts
where wawa_suppliers_to_haha_marketing_contacts.supplier_id IN
(select haha_supplier.supplier_id
where haha_supplier.supplier_id IN
(select haha_title_to_supplier.supplier_id from haha_title_to_supplier where haha_title_to_supplier.title_id = t.title_id)))
AS marketer,
select
group_concat(distinct concat(user.first_name,' ',user.last_name) separator ', ') AS editor
from user where user.id IN
(select wawa_suppliers_to_haha_editors.user_id from wawa_suppliers_to_haha_editors
where wawa_suppliers_to_haha_editors.supplier_id IN
(select haha_supplier.supplier_id
where haha_supplier.supplier_id IN
(select haha_title_to_supplier.supplier_id from haha_title_to_supplier where haha_title_to_supplier.title_id = t.title_id)))
AS editor,

我得到:

  ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '       from haha_supplier where haha_supplier.supplier_id IN
(select haha_title_to_supplier.supplier_id from haha_title_to_supplier where haha_title_to_supplier.title_id = t.title_id))'

这里有什么语法错误?

最佳答案

<罢工> 选择 t.title 作为标题, (选择 group_concat(distinct haha​​_supplier.display_name order by haha​​_supplier.display_name ASC 分隔符 ', ') AS 贡献者 来自 haha​​_supplier,其中 haha​​_supplier.supplier_id IN ^----

<罢工>

您缺少 where somefield在指定地点...

周一失明...把它留作个人发衫。

关于mysql - 复杂 MySQL 子查询的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35559172/

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