I’ve got this query which is quite specific and returns exactly what I need. As we know, nested queries in mysql can be pretty terrible in terms of runtime. If anyone could help me convert the following code to a JOIN statement, I would really appreciate it.
Any other optimizations are welcome and encouraged, of course.
SELECT title
FROM exp_channel_titles
WHERE entry_id IN (SELECT rel_child_id
FROM exp_relationships
WHERE rel_id IN (SELECT field_id_202
FROM exp_channel_data
WHERE entry_id = 19971));
Thank you!
The DISTINCT is there incase you have many:many relationships, etc, that may otherwise create duplicates.
In terms of optimisations, ensure each table has indexes on the fields that you use in JOINs and WHERE clauses.