user3518835
user3518835

Reputation: 115

Un recoginised keyword near like when i use Not Like in sql

i am trying to use not like in my sql query but it gives me error . please help.

SELECT word FROM school WHERE level  LIKE '%level%' AND NOT LIKE '%llevel%'

Upvotes: 1

Views: 69

Answers (4)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522741

Using REGEXP:

SELECT word
FROM school
WHERE level REGEXP '%[^l]level%'

This assumes that the matches you want are of the form of at least a single character followed by level, followed by zero or more characters. Your original query implies this to be the case.

Upvotes: 0

Carlos Rivero
Carlos Rivero

Reputation: 332

You are missing level before the NOT LIKE

SELECT word FROM school WHERE level  LIKE '%level%' AND level NOT LIKE '%llevel%'

Upvotes: 0

Andrey Korneyev
Andrey Korneyev

Reputation: 26886

You've missed level column name in second condition:

SELECT word FROM school WHERE level  LIKE '%level%' AND level NOT LIKE '%llevel%'

Upvotes: 1

Mr. Bhosale
Mr. Bhosale

Reputation: 3106

USe column name level for both condition.

      SELECT word FROM school WHERE level  LIKE '%level%' AND level  NOT LIKE '%llevel%'

Upvotes: 2

Related Questions