I've been tackling this for a long time and I've decided I will ask to see if someone can suggest something before my head explodes.
Here is the query I'm running, it's just repeating the same sub-sub-query multiple times within the sub-queries. I wanted to see what ALTERNATIVE options I have to speed this up.
All I can think so far is running an initial query then inserting the results for a second query.
Thanks in advance for anyones time looking at this.
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%"
)
)
)
)
)