How to select all id's except one?

4

Is there any way to in SQL I get all the data except an ID?

For example (I know this does not exist in SQL)

Select * From Utilizadores Where id_ut != 1; 
    
asked by anonymous 08.09.2015 / 01:31

2 answers

10

In addition to the way you've already done in your question, where you use not equal to (! =), you can do it in other ways:

Using other than :

Select * From Utilizadores Where id_ut <> 1;  

Using not in :

Select * From Utilizadores Where id_ut not in (1); 
/*Usando o not in, você pode passar uma lista de valores (1,2,10)*/

Remembering that you can use these 3 operators ( <> , != , not in ) not only with numeric values, but with texts as well. For example:

Select * From Utilizadores Where nome_ut not in ('João', 'Pedro', 'Maria'); 

Select * From Utilizadores Where nome_ut <> 'João'; 

Select * From Utilizadores Where nome_ut != 'João'; 
    
08.09.2015 / 12:19
1

Hi, do this:

Select * From Utilizadores Where id_ut <> 1; 
    
08.09.2015 / 02:01