Pregunta

Say I have a table with a field called foo. Foo is a character field. I want to return all records where foo is:

  1. Not in ('ad','ca','qw')
  2. Not like '9%' unless it is '96321'

Here is what I have but I am tripping up on how to get '96321'

SELECT 
    *
FROM
    mtable
WHERE
    foo NOT IN ('ad' , 'ca', 'qw')
        AND foo NOT LIKE '9%';
¿Fue útil?

Solución

Use OR condition, query will be as per below:

SELECT 
    *
FROM
    mtable
WHERE
    foo NOT IN ('ad' , 'ca', 'qw')
        AND (foo NOT LIKE '9%' OR foo='96321');
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top