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.
| Author |
Topic |
|
gschimenti
Starting Member
3 Posts |
Posted - 2005-05-30 : 08:24:26
|
| I need to compare two tables. one is a vendor master table and the other is an emplyee master. There are identicl fields like address1, address2, etc where I want to return the records that have the same values.If there is a match between address1 or address2 then show the record. If the values are empty in both tables ignore that record.I have this t-sql but it returns all records that don't match?select rc."Entry Date",rc."NIC Number",rc.TCIC,rc."Entered By", rc."Clear Date",rc."Cleared By",rc."Case Number" from rc left join tcic_entries on rc."Entry Date"=tcic_entries."Entry Date" and rc."NIC Number" = tcic_entries."NIC Number" and rc.TCIC = tcic_entries.tcic and rc."Entered By"=tcic_entries."Entered By" and rc."Clear Date" = tcic_entries."Clear Date" and rc."Cleared By" = tcic_entries."Cleared By" and rc."Case Number" = tcic_entries."Case Number"where tcic_entries."entry date" is null and tcic_entries."NIC Number" is null and tcic_entries.TCIC is null and tcic_entries."Entered By" is null and tcic_entries."Clear Date" is null and tcic_entries."Cleared By" is null and tcic_entries."Case Number" is nullis there a way to tweak this so that it gives me the records that match instead. any help is appreciated. Thanks! |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-05-30 : 23:18:29
|
| explore the group by clause, it'll remove the n-number of conditions in your where clause--------------------keeping it simple... |
 |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2005-05-31 : 01:59:03
|
| Why are you using a left join?HTH=================================================================The surest way to corrupt a youth is to instruct him to hold in higher esteem those who think alike than those who think differently. -Friedrich Nietzsche, philosopher (1844-1900) |
 |
|
|
gschimenti
Starting Member
3 Posts |
Posted - 2005-05-31 : 08:14:59
|
| Bustac and Jen,Thanks for the reply! I am using a left join because I have to link the tables? Don't I? and bustac can you explain what you mean about exxplore the group by clause it will remove the n number conditions?Thanks. |
 |
|
|
vivek.kumargupta
Starting Member
45 Posts |
Posted - 2005-05-31 : 10:48:02
|
| I think using a inner join on the two tables(vendor and master tables) on identical fields(the fields which you want to have same values ) of two tables will solve your problem.DOES IT ???Thanks, Vivek |
 |
|
|
gschimenti
Starting Member
3 Posts |
Posted - 2005-05-31 : 20:21:45
|
| Yes. I got it. Actually, just join worked. |
 |
|
|
|
|
|
|
|