June 13, 2009 at 1:13 am
Hi,
I have two table as below....
Table A Table B
id Name id Address
1 Sunil 1 Mumbai
2 Anil 3 Banglore
3 Raj 5 Chennai
4 Poonam
5 Amit
I want the result from these two table :
id name
1 Sunil
3 Anil
5 Amit
Please help me to get the result.
Thanks,
Sunil Kumar
June 13, 2009 at 1:32 am
Hi,
not clear in the table
create #tableA
(
ID1 int,
name1 varchar(10)
)
create #tableB
(
ID2 int,
Address varchar(10)
)
then what is the relation of these two table?
(it Should be some reletion like ID1 = ID2)
to get
id name
1 Sunil
3 Anil
5 Amit
ARUN SAS
June 13, 2009 at 3:31 am
Try this:
SELECT
tA.Id,
tA.Name
FROM TableA tA
JOIN TableB tB ON tA.Id = tB.Id
Flo
June 26, 2009 at 12:11 am
And then, based on the other thread where it looks like you want the names from TableA with no match in TableB:
SELECT
tA.Id,
tA.Name
FROM
TableA tA
LEFT OUTER JOIN TableB tB
ON tA.Id = tB.Id
WHERE
tB.ID is null;
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply