The question is not clear to me, are you talking about combining several sub-queries?
Maybe you should show an example (SSCCE) where you combined two "queries"?
My general advice is going for the better maintainable code with multiple short SQL-queries and only start optimizing when performance is bad.²
So maybe better "hashes" in your case, (whose keys I suppose are fed as row-IDs into the IN-clause ?)³
Anecdotal: I once wrote a very elaborated SQL code for complex tree manipulations in MariaDB, which was very fast, very atomic, and very nightmarish to test and maintain.
YMMV.¹
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
¹) Of course it's a matter of perspective. I once worked with a colleague who was uncomfortable with Perl and shifted most of the business logic into stored procedures. I'm sure he would object here.
²) In that case SQL-Window-Functions might(???) be what you really need.
³) TIMTOWTDI, you might also combine all row-IDs into a temporary SQL-table instead of using a Perl hash.
In reply to Re: Applying logical operators in either complex SQL xor hashes?
by LanX
in thread Applying logical operators in either complex SQL xor hashes?
by mldvx4
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |