Reputation: 11
I am trying to select a row where column C5721_USER_NAME
is not starting with "ccs" or C5721_USER_ORIGIN
is not starting by "ccs".
If either start with "ccs", I don't want that column.
Here is my query:
SELECT *
FROM T5707_ISSUES
WHERE (C5721_USER_ORIGIN NOT LIKE '%ccs%' OR C5721_USER_NAME NOT LIKE '%ccs%')
ORDER BY C5707_ISS_ID
But my results are for C5721_USER_NAME
:
cnewman
ctext
ccskym
lmbsiro
Upvotes: 0
Views: 114
Reputation: 3466
Please try this:
SELECT *
FROM T5707_ISSUES
WHERE (C5721_USER_ORIGIN NOT LIKE 'ccs%' and C5721_USER_NAME NOT LIKE 'ccs%')
ORDER BY C5707_ISS_ID
I've replaced or with and, as when you are using OR either of the columns having value starting with those characters can come up.
Upvotes: 1
Reputation: 15379
You're wrong logic operator OR instead of AND
SELECT *
FROM T5707_ISSUES
WHERE (C5721_USER_ORIGIN NOT LIKE '%ccs%' and C5721_USER_NAME NOT LIKE '%ccs%')
ORDER BY C5707_ISS_ID
Upvotes: 0
Reputation: 3012
If you only want it to search for records that don't start with the value you need to change your query to be:
SELECT *
FROM T5707_ISSUES
WHERE (C5721_USER_ORIGIN NOT LIKE 'ccs%' AND C5721_USER_NAME NOT LIKE 'ccs%')
ORDER BY C5707_ISS_ID
Upvotes: 0
Reputation: 46900
You have to use AND
SELECT *
FROM T5707_ISSUES
WHERE (C5721_USER_ORIGIN NOT LIKE 'ccs%' AND C5721_USER_NAME NOT LIKE 'ccs%')
ORDER BY C5707_ISS_ID
Also, to search for something that only starts
with ccs
you do not have to add an %
before it.
Upvotes: 2