It would be great if we could do sub queries (so using the IN() construct in MySQL) like this in one call to MySQL:
I know we can do it in two database queries, but this creates more traffic to the database server, so the ability to do it in one via the menu system would be great!
Yes, but you and George keep asking me to do as much as possible using the menus, so I am telling you when I cannot!
I was thinking, a solution to this might be to have a previous database query that is disabled, but allow that to be selected as the subquery of what follows…
Avoid subqueries as much as possible unless you really know how to optimise them. Eventually you will end up hindering the performance of your app because you used a subquery where should have not
All in all, people tend to resort quickly to IN because it seems more intuitive. And while in some contexts that is OK. In others it’s a bad choice performance wise.
The problem is that sometimes JOIN and EXISTS won’t yield the same results as IN. For that to happen, you can sometimes rewrite the query, others you can redesign the database and others you have to stick with IN.
I’m generally in favour on any features which make development easier but I think once you go beyond standard queries (and the query builder already has more functionality than most automated builders offer) you are better off just having a custom queries option. This means there is no limit at all. Once you venture down the road of sub-queries, where do you stop?