hiddenpearls — 2011-08-21T05:54:39-04:00 — #1
I'm confused about AND/OR NOT LIKE in mysql query ..
my query is like this
select * from news_view WHERE collection_id = 18259 and ((news_headline NOT like '%Kim%' OR news_summary NOT like '%Kim%')) order by pub_date desc
it returns the records that contains the word 'Kim' in news_summary though It shouldn't .. but when I use AND it returns results ok i.e it doesn't return the records that contains word 'Kim'
I want to make it like this, if 'Kim' presents in both fields or in one of the fields it shouldn't appear ..
r937 — 2011-08-21T06:44:52-04:00 — #2
hiddenpearls — 2011-08-21T06:53:18-04:00 — #3
confused when I used AND ... it shouldn't show when word is present in news_summary and not in news_headline ..
hiddenpearls — 2011-08-21T07:33:26-04:00 — #4
Following works great btw,
select * from news_view WHERE collection_id = 17743 AND NOT (news_headline like '%Kim%' OR news_summary like '%Kim%') order by pub_date desc
r937 — 2011-08-21T08:07:37-04:00 — #5
NOT (x OR y) is the same as NOT x AND NOT y
hiddenpearls — 2011-08-21T08:28:14-04:00 — #6
oo Yes, you are right!