Select with "different" expression with two conditions

Asked

Viewed 10,554 times

5

I wonder if there’s any way to make a select using a where for a field with the parameter other than < >, where it has two or more items.

To facilitate follow example:

select * from TAB_DESPESAS where cd_item <> '0' order by cd_processo;

For this query I have more than one code for the field cd_item, which in this case would be a sort of list (codes: 0, 2, 20 and 21). Therefore, I would like to bring in this query all other items, except the list items.

2 answers

7


Use the NOT IN

select * from TAB_DESPESAS where cd_item NOT IN ('0','2','20','21') order by cd_processo;
  • Thank you so much for your help, @LINQ.

2

You can use the following command:

SELECT * FROM tabela WHERE COD_STATUS NOT IN ('2','10','5')

Browser other questions tagged

You are not signed in. Login or sign up in order to post.