i once wanted to to this:

SELECT events.b_g FROM events WHERE events.b_g NOT IN ( SELECT otf.b_g FROM otf ) AND events.b_g NOT IN ( SELECT requests.b_g FROM requests)

and this...

... WHERE events.b_g IN ( SELECT otf.b_g FROM otf ) OR events.b_g IN ( SELECT requests.b_g FROM requests ) ...

instead i had to do this:

SELECT events.b_g, events.vector, SUM(tries) AS 'attempts', COUNT(DISTINCT events.observer) AS 'reporters' FROM events LEFT JOIN otf ON events.b_g = otf.b_g LEFT JOIN requests ON events.b_g = requests.b_g WHERE requests.b_g IS NULL AND otf.b_g IS NULL GROUP BY events.b_g, events.vector ORDER BY events.b_g, events.vector, 'attempts'

and...

... WHERE requests.b_g = events.b_g OR otf.b_g = events.b_g ...

this might or might not help.


In reply to Re: DBI question with placeholders and IN by zengargoyle
in thread DBI question with placeholders and IN by dragonchild

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.