admin管理员组

文章数量:1193805

I have a strange issue running this MySQL query:

                           SELECT
                            aid, listingStatus
                           FROM
                            navigation_token_assignment,
                            article
                           WHERE
                            navigation_token_assignment.aid=article.id
                            AND navTokenId=29
                            AND listingStatus NOT IN (3,4)
                            AND id=2001451
                            LIMIT 1;

This Code returns this answer:

     aid     | listingStatus
     2001451 | 4

Why is NOT IN not resolved correctly? The xpeceted outcome would be Nothing (or at least not listingStatus=4).

It also does not work with AND listingStatus!=3 AND listingStatus!=4

What would be a possible fix to this problem?

I have a strange issue running this MySQL query:

                           SELECT
                            aid, listingStatus
                           FROM
                            navigation_token_assignment,
                            article
                           WHERE
                            navigation_token_assignment.aid=article.id
                            AND navTokenId=29
                            AND listingStatus NOT IN (3,4)
                            AND id=2001451
                            LIMIT 1;

This Code returns this answer:

     aid     | listingStatus
     2001451 | 4

Why is NOT IN not resolved correctly? The xpeceted outcome would be Nothing (or at least not listingStatus=4).

It also does not work with AND listingStatus!=3 AND listingStatus!=4

What would be a possible fix to this problem?

Share Improve this question edited Jan 23 at 16:55 Levi Pike asked Jan 23 at 16:45 Levi PikeLevi Pike 1951 silver badge8 bronze badges 1
  • With Join it does not work, either: SELECT aid, listingStatus FROM navigation_token_assignment JOIN article ON navigation_token_assignment.aid=article.id WHERE navTokenId=29 AND listingStatus NOT IN (3,4) AND id=2001451 LIMIT 1; – Levi Pike Commented Jan 23 at 16:52
Add a comment  | 

1 Answer 1

Reset to default 5

Just a guess: try to check the type of listingStatus, maybe it's not an integer and type casting is needed here

本文标签: MySQL NOT IN () does not exclude wenn connecting 2 TablesStack Overflow