> When there is more than one query, there will be an operator XOR, AND, OR, or NOT applied between them.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.