0

I have this query:

 select * from m3fdbprd.cmnusr
 where juultp = 1
 and jutx40 <> LIKE 'M3%' OR jutx40 <> LIKE 'MeC%'
 order by jutx40

I am getting an error:

SQL0104 - Token 'M3%' was not valid. Valid tokens: FOR USE SKIP WAIT WITH FETCH LIMIT ORDER UNION EXCEPT OFFSET.

where I am trying to do a multiple like, I am running this query to display all values in m3fdbprd.cmnusr where in the column jutx40 the value does not start with M3 or Mec.

Can you please advise?

I am running against an MS sql server database.

1
  • 2
    SQL0104 does not looks like a SQL Server error message. Googling shows that is is more likely DB2 Commented Apr 3, 2018 at 11:17

3 Answers 3

5

Use NOT LIKE. I'm also pretty sure you want AND and not OR:

select *
from m3fdbprd.cmnusr
where juultp = 1 and
      jutx40 not like 'M3%' and jutx40 not LIKE 'MeC%'
order by jutx40
Sign up to request clarification or add additional context in comments.

Comments

2

You should use NOT instead of <>

 select * from m3fdbprd.cmnusr
 where juultp = 1
 and jutx40 NOT LIKE 'M3%' OR jutx40 NOT LIKE 'MeC%'
 order by jutx40

Comments

0

Another approach is to use NOT with parentheses:

SELECT * FROM m3fdbprd.cmnusr
WHERE juultp = 1
AND NOT (jutx40 LIKE 'M3%' OR jutx40 LIKE 'MeC%')
ORDER BY jutx40

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.