Connecting Tech Pros Worldwide Help | Site Map

Matching the first 3 letters of the field

  #1  
Old July 2nd, 2008, 03:45 PM
nofear
Guest
 
Posts: n/a
I have 2 tables with 1 field each
the filed of the fist table has a 3 digit number stored as text
and the field of the second table has a 6 digit number stored as text

I'd like to select each 6 digit number where the first 3 digits match
the field in the first table

I'm not sure If I can use the "LIKE"
  #2  
Old July 2nd, 2008, 04:25 PM
Allen Browne
Guest
 
Posts: n/a

re: Matching the first 3 letters of the field


You can use LIKE in the FROM clause, like this:

SELECT Table1.*
FROM Table2 INNER JOIN Table1
ON Table2.[SomeField] Like Table1.[SomeField] & "*"

Access will not be able to display this query graphically (i.e. it's SQL
View only), and results will be read-only.

An alternative approach (probably more efficient) would be to create a query
that uses integer division to lose the least-significant 3 digits from table
2:
SELECT [SomeField] \ 1000 AS MyAlias
FROM Table2;

You could then use that query as in input table, and join it to Table1. This
will display graphically.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"nofear" <eurolinux@hotmail.comwrote in message
news:66d4f25d-5a29-4aca-9ed5-d8050e4a4d34@k37g2000hsf.googlegroups.com...
Quote:
>I have 2 tables with 1 field each
the filed of the fist table has a 3 digit number stored as text
and the field of the second table has a 6 digit number stored as text
>
I'd like to select each 6 digit number where the first 3 digits match
the field in the first table
>
I'm not sure If I can use the "LIKE"
  #3  
Old July 2nd, 2008, 06:05 PM
nofear
Guest
 
Posts: n/a

re: Matching the first 3 letters of the field


Thx


On Jul 2, 11:20*am, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
Quote:
You can use LIKE in the FROM clause, like this:
>
SELECT Table1.*
FROM Table2 INNER JOIN Table1
* * ON Table2.[SomeField] Like Table1.[SomeField] & "*"
>
Access will not be able to display this query graphically (i.e. it's SQL
View only), and results will be read-only.
>
An alternative approach (probably more efficient) would be to create a query
that uses integer division to lose the least-significant 3 digits from table
2:
* * SELECT [SomeField] \ 1000 AS MyAlias
* * FROM Table2;
>
You could then use that query as in input table, and join it to Table1. This
will display graphically.
>
--
Allen Browne - Microsoft MVP. *Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
>
"nofear" <euroli...@hotmail.comwrote in message
>
news:66d4f25d-5a29-4aca-9ed5-d8050e4a4d34@k37g2000hsf.googlegroups.com...
>
Quote:
I have 2 tables with 1 field each
the filed of the fist table has a 3 digit number stored as text
and the field of the second table has a 6 digit number stored as text
>
Quote:
I'd like to select each 6 digit number where the first 3 digits match
the field in the first table
>
Quote:
I'm not sure If I can use the "LIKE"
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 13th, 2005 09:56 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 13th, 2005 03:15 AM
How to Compare Autonumbers and Return the Larger Value, and try to Assign it to a Bound Field Megan answers 2 November 13th, 2005 02:41 AM
Data can't be saved to the field Georges Heinesch answers 10 November 12th, 2005 05:35 PM