MySQL Forums
Forum List  »  Newbie

Re: help improving 'join' efficiency in sub-querys
Posted by: Peter Brawley
Date: September 19, 2016 08:00AM

> the problem is that I now have to add other "questions"
> so where frm_req.id = 336, 337, 338 etc as their own columns
> without creating additional rows.

The desired result is multi-column with each column the result of a query like the one for req_id=335?

You could pivot on req_id to build the Select list. Without aggregation, that's easier to write in the app language. The query would be a lot faster than correlated subqueries, which have to repeat all those joins for each row.

Plan B: save such single column results to a result table, and display the whole thing at the end. Assuming this query is needed often, you could keep the result table and building updating of it into the database and/or into the apps.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.