Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between two tables

Status
Not open for further replies.

lyric0n

Technical User
Joined
Dec 28, 2005
Messages
74
I am having difficulty coming up with a SQL statement to do the following...

If I have T1 with rows 1, 2, 3 and T2 with rows 1, 2. How would I create a SQL statement to just show row 3 from T1?

Thanks,
Chris
 
a self join ought to help you.

can i have some data so that i can provide you with an example???

Known is handfull, Unknown is worldfull
 
Sure..

T1:
ID | Name | State
1 | Chris | Ohio
2 | John | Maryland
3 | Sally | Washington

T2:
ID | Name | State
1 | Chris | California
2 | John | Maryland

I guess I should also modify my question a bit, since the State in this case changes, I would need to see records 1 and 3 in my result.

Thanks,
Chris
 
I see this as
Code:
select a.ID, a.State from T2 a inner join T1 b 
on a.Name = b.Name and a.State != b.State

<.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top