mysql - MySql,UNION 时重复 Select IN (Select()) 的替代方法
问题描述
我已经解决这个问题很长时间了,我决定我会在我的脑袋爆炸之前询问是否有人可以提出一些建议。
这是我正在运行的查询,它只是在子查询中多次重复相同的子子查询。我想看看我必须有哪些替代选项来加快速度。
到目前为止,我所能想到的只是运行一个初始查询,然后插入第二个查询的结果。
提前感谢任何人花时间看这个。
SELECT t2.* FROM TABLEA as t2 where
t2.link_id in
(
select t4.LinkA as link_list from TABLEB as t4
where t4.LinkB in (
select t1.id from TABLEC as t1 where t1.number in
(
(select t2.number from TABLEC as t2 where t2.id in
(
select t3.link_id from TABLEA as t3 where t3.an like "%20278%"
)
)
)
)
union
select t4.LinkB as link_list from TABLEB as t4
where t4.LinkB in (
select t1.id from TABLEC as t1 where t1.part_number in
(
(select t2.number from TABLEC as t2 where t2.id in
(
select t3.link_id from TABLEA as t3 where t3.an like "%20278%"
)
)
)
)
union
select t4.LinkA as link_list from TABLEB as t4
where t4.LinkA in (
select t1.id from TABLEC as t1 where t1.number in
(
(select t2.number from TABLEC as t2 where t2.id in
(
select t3.link_id from TABLEA as t3 where t3.an like "%20278%"
)
)
)
)
union
select t4.LinkB as link_idlist from TABLEB as t4
where t4.LinkA in (
select t1.id from TABLEC as t1 where t1.number in
(
(select t2.number from TABLEC as t2 where t2.id in
(
select t3.link_id from TABLEA as t3 where t3.an like "%20278%"
)
)
)
)
)
解决方案
推荐阅读
- css - 图像悬停时的css下拉菜单
- swift - Swift:绘图开始时图像丢失纵横比
- c# - Azure Active Directory B2C 未反序列化 MVC 项目中的 httpContext.Session
- amazon-web-services - AWS Lambda 内部的 Parameter Store 请求超时
- google-cloud-pubsub - Pubsub 以稳定的速度拉动?
- html - 如何对齐段落?
- php - 我的php编码有什么问题?[将图像从 html 表单保存到数据库]
- python - 如何限制稀疏梯度每个维度的绝对值过大?
- python - 使用 Python 从 PDF 多页列中提取字符串数据
- c# - 未找到 C# 递归依赖项