SQL Check not working

  • I'm trying to check for 2 things

    1) If There is a record that exists in phones with good = null or good = 1

    AND

    2) There is a record that exists in the extradata table with extracode of UU for any records found in #1

    this isn't doing it. It's finding a bunch of records but I think it's ignoring the check for extradata table because there is no with ST for this account # so really, this select should be returning nothing:

    SELECT 1

    from phones p (NOLOCK)

    inner join master m on m.number = p.number

    INNER JOIN extradata e ON e.number = m.number

    where ((p.good is null) or (p.good = 1))

    and m.number = 672439

    and e.extracode = 'UU'

  • What's with the 'with ST'...? The example is querying for 'UU'..?

    If you look stright in the extracode table for the account, how does that look?

    You could also try to change the 1/null check to COALESCE(p.good, 1) = 1

    ..and see of the 'or' stuff is messing things up in some way.

    /Kenneth

  • ST is just an inconsistency, I forgot to put UU in my post.  Thanks for the suggestion!

  • So, do you still have the problem?

    If you do, please post some sample data and the offending query to reproduce it.

    /Kenneth

  • no more issues here, I've figured it out...thanks

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply