Search code examples
mysql

MySQL NOT IN () does not exclude wenn connecting 2 Tables


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?


Solution

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