I have two MySQL tables within the same Database that I need to compare. One is masterTxn
, which essentially is a master list of transactions that I need to compare with another table, month_tbl
.
My goal is to compare masterTxn
with month_tbl
and find the transactions that are within masterTxn
but are not in month_tbl
. I've tried the following, but it returns 0 rows, when I know there are definitely at least 300-400 rows that should match this query:
SELECT * FROM masterTxn WHERE masterTxn.TxnID NOT IN (SELECT month_tbl.TXNID FROM month_tbl)
As you can see, I'm trying to compare using the TXNID
column in each of the tables. However, here's the catch: There are multiple rows with the same TXNID
value. In other words, there is no primary key or identifier for either of these tables—although I wish I could change that, that is how the data is written from it's source.
I've tried several things from these other posts:
MySQL "NOT IN" query
Get a result by comparing two tables with an identical column
But these ideas haven't worked... Perhaps I'm implementing them wrong, but it seems like each of these other posts has a column where there is no other row that has the same value.
Any ideas?
Thanks in advance!!