MySQL Forums
Forum List  »  MySQL Query Browser

Compare Two Table Columns Using LIKE
Posted by: Danny Rilago
Date: October 20, 2010 11:59AM

hello all - can anyone help me with comparing 2 tables to find unmatched records? I have found countless posts regarding this, but nothing has worked for me, so I'm screwing something up somewhere...

I have billing table and slas table - want to compare the value of two columns with a like clause. The billing.applcode can contain values that are like values of slas.parent_applcode, such as: billing.applcode can contain 'Q10A', 'Q10B', 'Q10C', whereas the slas.parent_applcode will only have 'Q10'


Here's what I have, but it returns all values from billing:

//FIND RECORDS IN BILLING THAT AREN'T IN SLAS//
SELECT * FROM billing
WHERE billing.applcode
NOT IN (
SELECT slas.parent_applcode
FROM slas
WHERE billing.applcode LIKE CONCAT('%', slas.parent_applcode, '%'))

Thanks in advance for your help.

Options: ReplyQuote


Subject
Written By
Posted
Compare Two Table Columns Using LIKE
October 20, 2010 11:59AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.