Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 selecting records from one table using another table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-02 : 11:09:27
Mauro writes "Hi,
It's a little harder for to explain my doubt because i'm portuguese and i can't spell ou write very well.
But my question is:

I have two tables and i want to select all items from table T1 less some records from table T2


T1: T2:
--- ---
city user city
..... .... ....
Lisbon mdfa Porto
Porto nmdb Lisbon
Coimbra


And i was expecting to achieve:

Lisbon and Coimbra from T1, because i want all cities from T1 less teh cities in T2 where user=mdfa.

Thx"

M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-07-02 : 11:23:45
subquery time

select city
from t1
where city not in (select city from t2 where user = 'mdfa')

-----------------------
Take my advice, I dare ya
Go to Top of Page
   

- Advertisement -