Left joining table with existing data negative match I have a table (TYPE_GOODS_ASSOC) set up like this:

ID| TYPE_ID| GOOD_ID 
1 |   1    |   2


Another table (X) is like this:

ID| GOOD_NAME          | GOOD_ID 
1 |   'Something'      |   1
1 |   'Something else' |   2


I have both GOOD_ID and TYPE_ID, and am trying to left join X to TYPE_GOODS_ASSOC to find the records with certain TYPE_ID that are not present in the table. Here is a part of the query:

SELECT * FROM table X
LEFT JOIN TYPE_GOODS_ASSOC on TYPE_GOODS_ASSOC.GOOD_ID = X.GOOD_ID
WHERE TYPE_GOODS_ASSOC.GOOD_ID is NULL AND TYPE_ID = 2


I don't get anything back. And maybe I m not writing the query right. Since I have existing entries with TYPE_1, I m looking for the GOOD_ID(s) where TYPE_ID is 2 and they don't have entry in the TYPE_GOODS_ASSOC table. What am I doing wrong here? 

Desired result is :

1 |   'Something'      |   1 - which is ID 1 from Table X
I think you need a simple anti-semijoin. Either with LEFT JOIN - IS NULL:

SELECT x.* 
FROM table_X AS x
    LEFT JOIN TYPE_GOODS_ASSOC AS g
    ON g.GOOD_ID = x.GOOD_ID
WHERE g.GOOD_ID IS NULL ;


or with NOT EXISTS:

SELECT x.* 
FROM table_X AS x
WHERE NOT EXISTS
      ( SELECT 1
        FROM TYPE_GOODS_ASSOC AS g
        WHERE g.GOOD_ID = x.GOOD_ID
      ) ;