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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax for Joining on a range 1

Status
Not open for further replies.

awesomeBA

Technical User
Jun 1, 2005
24
US
I would like to create a join using a range. Do I need to indicate that the match will be a range of the field in the second table?
 
Hi!

Just do a standard join and limit the field from the second table in the Where clause.

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Something like this ?
ON A.SomeFiled Between B.Field1 And B.Field2

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The fields that i am trying to join on are both serial number fields.
T1 contains the entire number t2 contains 5 digits of the serial number.
 
Hi!

You can do this:

table1 Inner Join table2 On Left(table1.T1, 5) = table2.t2

If the fields are number fields then you can wrap table1.T1 and table2.t2 in a Format function.

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Both are number field s but no calcs are necessary just a match. Does the format function give me value in this area?
 
Hi!

The format function will just change the number to a string so that the Left function will work on it. Also, I made the assumption that t2 contained the first 5 digits from T1. If that isn't the case then let us know and we can get you the appropriate function to match what you want. One alternative would be:

table1 Inner Join table2 On InStr(Format(table1.T1), Format(table2.t2)) <> 0

This will match if t2 is anywhere in T1. But that may get you matches that you don't want. It just depends on exactly how the two fields are related.

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
I think the second query will give me what I need. Have a star!!!

Tks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top