0

I have 2 tables, catalog and seriesTitle.

I need to select instances of SERIES_CODE that exist in one table, but not the other, as follows:

SELECT SERIES_CODE 
FROM catalog 
WHERE SERIES_CODE NOT IN 
    (SELECT SERIES_CODE 
     FROM seriesTitle)

The query executes successfully, and results are returned.

However, the results are incomplete. I am 100% positive that there are some SERIES_CODEs that exist in catalog, but not seriesTitle.

I have checked that the type and collation of SERIES_CODE is the same in both tables.

Is it possible there is some data corruption, or other issue other than the simple query above? Or perhaps my query is wrong somehow? (I'm not worried about performance right now, just results!)

Simon
  • 1
  • 2
  • 1
    SELECT SERIES_CODE FROM catalog a WHERE SERIES_CODE (SELECT SERIES_CODE FROM seriesTitle b where a.id!=b.id) – Álvaro Touzón Jul 18 '17 at 08:21
  • Please show some sample data which makes your problem reproducible. Don't leave use guessing here. – Tim Biegeleisen Jul 18 '17 at 08:25
  • The query syntax is fine, although I prefer using the `LEFT JOIN - NULL` pattern. See https://stackoverflow.com/questions/21633115/return-row-only-if-value-doesnt-exist?lq=1 – Barmar Jul 18 '17 at 08:29

0 Answers0