NOT LIKE not working on comparison to a column

Posted by rodling on Stack Overflow See other posts from Stack Overflow or by rodling
Published on 2012-12-13T16:16:15Z Indexed on 2012/12/13 17:03 UTC
Read the original article Hit count: 160

Filed under:

Data is fairly large and takes few minutes to run it every time, so its taking a lot of time debugging this problem. When I run like concat('%',T.item,'%') on smaller data it seems to identify items properly. However, when I run it on the main DB (the code shown), it still shows many(maybe even all) of the exceptions.

EDIT: it seems when i add NOT it stops identifying items

select distinct T.comment
from (select comment, source, item from data, non_informative where ticker != "O" and source != 7 and source != 6) as T
where T.comment not like concat('%',T.item,'%')
order by T.comment;

comment and source are in data, item is in non_informative

Some items from T.item:

'Stock Analysis -', '#InsideTrades', 'IIROC Trade'

Example comment which should be removed

'#InsideTrades #4 | MACNAB CRAIG (Director,Officer,Chief Executive Officer): Filed Form 4 for $NNN (NATIONAL RETA'

Can't seem to figure out it why shows all the items

© Stack Overflow or respective owner

Related posts about mysql