Home » SQL & PL/SQL » SQL & PL/SQL » Query
Query [message #10495] Mon, 26 January 2004 18:12 Go to next message
blazix
Messages: 6
Registered: October 2003
Junior Member
Hi all,

I am newbie to SQL.I need query for below.

Table1(Name,City)

Column values Blazix,Atlanta

                    Derrick,New Jersey

                    Blazix, New York

I need all the names who does not stay in Atlanta .I should not get Blazix name in the o/p.

Please advise me the appropriate query .

Thanks

Blazix

 

 
Re: Query [message #10496 is a reply to message #10495] Mon, 26 January 2004 18:32 Go to previous messageGo to next message
Rishi
Messages: 63
Registered: January 2001
Member
Select name,city from table1 where city not in ('Atlanta');
Re: Query [message #10498 is a reply to message #10495] Mon, 26 January 2004 20:59 Go to previous messageGo to next message
Prashanth
Messages: 41
Registered: September 1999
Member
select name
from table1
where city not in 'Atlanta'
and name not in 'Blazix';
Re: Query [message #10499 is a reply to message #10495] Mon, 26 January 2004 23:24 Go to previous messageGo to next message
William Robertson
Messages: 1643
Registered: August 2003
Location: London, UK
Senior Member
SQL> create table table1 (name varchar2(20), city varchar2(20));

Table created.

SQL> insert all
  2  into table1 values ('Blazix','Atlanta')
  3  into table1 values ('Derrick','New Jersey')
  4  into table1 values ('Blazix','New York')
  5  select * from dual;

3 rows created.

SQL> SELECT name FROM table1
  2  MINUS
  3  SELECT name FROM table1
  4  WHERE  city = 'Atlanta';

NAME
------------------------------
Derrick

1 row selected.

SQL> SELECT name FROM table1 t1
  2  WHERE  NOT EXISTS
  3         ( SELECT 1 FROM table1
  4           WHERE  name = t1.name
  5           AND    city = 'Atlanta' )
  6

NAME
------------------------------
Derrick

1 row selected.
Re: Query [message #10516 is a reply to message #10495] Tue, 27 January 2004 21:36 Go to previous message
georphin
Messages: 3
Registered: January 2004
Junior Member
answer from prashanth is perfect
Previous Topic: here's a good one!
Next Topic: Amateur
Goto Forum:
  


Current Time: Thu Apr 25 03:47:10 CDT 2024