Steve
Steve

Reputation: 2588

MySQL NOT LIKE with a condition

My columns are as follows:-

What I want to do within my query is to select all rows where path is not like '% node/ %', but there is one exception to this.

I want this row with path 'node/109' to show.

This is what I did:-

SELECT 
      COUNT(path) as hits, path as link, MAX(title) as page FROM accesslog 
WHERE 
      MONTH(FROM_UNIXTIME(timestamp)) = 11 
      AND path NOT LIKE '%node/%' 

GROUP BY path ORDER BY hits DESC

Possible?

Upvotes: 0

Views: 322

Answers (1)

Rahul
Rahul

Reputation: 77866

Then what if you change it to that specifically (with parenthesis)

AND ( path LIKE '%node/109%'
      OR path NOT LIKE '%node/%')

Upvotes: 2

Related Questions