Hi all,
I need a small help in creating a join query in sql.My two tables are A and B. A has got columns id, dname, counter and date. B has got two columns link and date. The primary key of A is the column Id whereas in table B, both are primary keys(composite key).
I need to get the records (id,dname,counter) from A which has nocorresponding link in table B.To be precise, If the table A has fields (id,dname,counter) (1,abc,2000)and if table B has no record for abc, this row should be returned from A.
I hope using left outer join will help me in getting my desired result.
I hope someone will be able to help me out.
Thanking all in advance for your valuable time.
To restate the problem, you want to know all the records in table A that do not have a corresponding record in table B?
create table a (id int, dname varchar(10), counter int)
create table b (dname varchar(10))
insert into table a (1,'abc',2000)
insert into table a (2,'def', 4000)
insert into table b ('def')
select
a.id
,a.dname
,a.counter
from a
where a.dnamenotin(select b.dnamefrom b)
No comments:
Post a Comment