Sorry misunderstood your last one.
I see that you're getting into the dangerous world of partial
matches. My general solution was based on the fact that you had a
number followed by a letter. (and my solution would have been somewhat
flawed in that point) Now there are may more variables, for example:
table1:
200
table2:
Product 200
200b
2000c (original solution flawed in this case)
1200
To query this is hazardous. Maybe this... but it will only work for
the cases I have listed above:
SELECT TableA.simField, TableB.simField
FROM TableA, TableB
WHERE TableB.simField Like [TableA].[simField] & "?*"
OR TableB.simField Like "* " & [TableA].[simField]
OR TableB.simField Like "* " & [TableA].[simField] & " *"
OR TableB.simField Like [TableA].[simField] & " *"
Case 1: 200a (has only the number followed by a character)
Case 2: Product 200 (end with number after space)
Case 3: BLAH 200 Blah (spaces surrounding the number)
Case 4: 200 blah (start with number followed by space)
BTW,
? is used to represent a single character
* is used for any number of characters or digits
This should be enough for you to work with.
Cheers,
Jason Lepack
Sorry guys,
Still this seem to bring up some results but not the ones with longer names
ie "Product 200" to just "200". I cant change the data as is what is
extracted from the main database.
Any other ideas?
Matt
John Spencer said:
You cannot use the query grid to build a non-equi join (equi joins are those
where field(s) in tableA are equal to field(s) in tableB.
You can do this in the SQL window.
UPDATE TableB INNER JOIN TableA
ON TableB.Model LIKE TableA.Model & "*"
SET TableB.SomeField = [TableA].[SomeOtherField]
Also, you could build a query using the query grid (Design view) and
"normal" joins and then switch to SQL view and replace
ON TableB.Model =TableA.Model
With
ON TableB.Model LIKE TableA.Model & "*"
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
Just replace the "simField" with the name of the fields that are
similar.
SELECT TableA.simField, TableB.simField
FROM TableA, TableB
WHERE TableB.simField Like [TableA].[simField] & "*";
On Feb 12, 10:54 am, Matt Dawson
Is it possible to create a like relationship?
I have two tables but one contains variations on the other ie setup per
machine and are called different models.
For example in Table A i will have a 123 and need this to be linked to
Table
B where it will have the 123a and 123b listed! I need to add one field
from
table A to table B.
Is there anyway of doing this?
Many Thanks,
Matt- Hide quoted text -
- Show quoted text -