Select with two conditions

Asked

Viewed 284 times

0

How do I select users who have code other than 0 and 573?

For example, this is my table:

 Usuario Codigo
    1        573
    2        0
    3        0
    4        100
    5        520

I need to select only users who have the code DIFFERENT from 0 and 573.

  • 1

    Have you studied SQL before? If yes, you must have tried to do something, what? Could you show us your attempt?

  • @user134546, have any of the answers solved your problem? Vote for those that have been useful to you: Why it is important to vote?

2 answers

2

You have two choices:

SELECT  * 
FROM    MinhaTabela 
WHERE   Codigo <> 0 
    AND Codigo <> 573

Or:

SELECT  * 
FROM    MinhaTabela 
WHERE   Codigo NOT IN (0, 573)

1

SELECT * FROM TABELA WHERE CODIGO <> 0 AND CODIGO <> 573

Browser other questions tagged

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