Vincent Vincent - 9 months ago 36
SQL Question

Converting complex SQL to JOIN

I have the following SQL statement. Which is working okay. Except in some cases the processing of the query takes a lot of time, resulting in a system time out. So I need to convert the statement. Probably with a JOIN.

I can't figure out how to convert this statement:

SELECT as id,

FROM table1, table2, table3, table4, table5

WHERE = table2.tabel1id
AND table2.table2id = table3.table2id
AND table3.table3id = table5.table3id
AND table5.somecode = '5'
AND table3.table3id =
AND table1.firstname LIKE '%John%'

ORDER BY, table1.firstname, table1.lastname

I have the nesting of the tables and I also want to use the results of subqueries in the final SELECT ( and

from table1 as t1 
inner join table2 as t2 on 
inner join on table3 as t3 on t2.table2id=t3.table2id
inner join on table4 as t4 on
inner join on table5 as t5 on t5.table3id=table3.table3id 
where t1.firstname like '%John%' and t5.somecode='5'
group by
order by,t1.firstname,t1.lastname