Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
SQL query with join on substring
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
SriramNA  
View profile  
 More options Jun 23 2012, 3:39 am
Newsgroups: microsoft.public.access.queries, microsoft.public.access.reports
From: "SriramNA" <M8R-ai1...@mailinator.com>
Date: Sat, 23 Jun 2012 13:09:49 +0530
Local: Sat, Jun 23 2012 3:39 am
Subject: SQL query with join on substring
I have two tables imported into Access.

Sample data:
1.  Asset table, containing -
AssetNumber    Owner    CapitalizationDate    ReferenceData
300137015    ABC    23/4/2005    61708
300287721    DEF    22/1/2007    45709
300338450    GHQ    12/7/2009    37154

2.  ITEqpt table, containing -
EquipmentID    LastUser    UsedDate
OKL61708    XYZ    12/4/2012
JA37154    ABC    22/5/2012

and so on.

I need to list all records in the Asset table which have a corresponding
record in the ITEqpt table.

The problem is that the key fields in the two tables are recorded slightly
differently - the ReferenceData in the Assets table typically contains a
substring of the EquipmentID value in the ITEqpt table.

How do I make a report with a join like
ReferenceData = substring in EquipmentID?

--
Sriram


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
JHB  
View profile  
 More options Jun 23 2012, 5:58 am
Newsgroups: microsoft.public.access.queries, microsoft.public.access.reports
From: "JHB" <jhb...@hotmail.com>
Date: Sat, 23 Jun 2012 11:58:11 +0200
Local: Sat, Jun 23 2012 5:58 am
Subject: Re: SQL query with join on substring

"SriramNA" <M8R-ai1...@mailinator.com> skrev i en meddelelse news:js3rs4$35c$1@dont-email.me...

Hello,
If the lenght always is 5, then you can use this:  
Assettable.ReferenceData = clng(right(ITEqpttable.EquipmentID,5))

Jørn


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
SriramNA  
View profile  
 More options Jun 23 2012, 8:22 am
Newsgroups: microsoft.public.access.queries, microsoft.public.access.reports
From: "SriramNA" <M8R-ai1...@mailinator.com>
Date: Sat, 23 Jun 2012 17:52:59 +0530
Local: Sat, Jun 23 2012 8:22 am
Subject: Re: SQL query with join on substring
Um.. that'll catch most of them, but there are many exceptions...

Isn't there a way of simply stripping non-numeric characters from
EquipmentID value?

--
Sriram

"SriramNA" <M8R-ai1...@mailinator.com> skrev i en meddelelse
news:js3rs4$35c$1@dont-email.me...

Hello,
If the lenght always is 5, then you can use this:
Assettable.ReferenceData = clng(right(ITEqpttable.EquipmentID,5))

Jørn


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bob Barrows  
View profile  
 More options Jun 23 2012, 9:28 am
Newsgroups: microsoft.public.access.queries, microsoft.public.access.reports
From: "Bob Barrows" <reb01...@NOSPAMyahoo.com>
Date: Sat, 23 Jun 2012 09:28:34 -0400
Local: Sat, Jun 23 2012 9:28 am
Subject: Re: SQL query with join on substring
Assuming that the first numeric character is never followed by non-numeric
characters, the Val function will work.
On clng(ReferenceData) = Val(EquipmentID)

If the assumption is incorrect, then you can use 26 nested Replace
functions:

On Replace(Replace(Replace(EquipmentID,"A",""),"B",""),"C","") etc.

or write a function that loops through each character in the EquipmentID,
appending it to a variable if numeric.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
JHB  
View profile  
 More options Jun 23 2012, 11:37 am
Newsgroups: microsoft.public.access.queries, microsoft.public.access.reports
From: "JHB" <jhb...@hotmail.com>
Date: Sat, 23 Jun 2012 17:37:36 +0200
Local: Sat, Jun 23 2012 11:37 am
Subject: Re: SQL query with join on substring
No, it isn't any easy solution, and the VAL function can't be used because the Val function stops reading the string, at the first character it can't recognize as part of a number.

See this knowledge base article, how you can build a functin you can use in a query;
http://support.microsoft.com/kb/210537

Jørn

"SriramNA" <M8R-ai1...@mailinator.com> skrev i en meddelelse news:js4cf4$o7f$1@dont-email.me...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
SriramNA  
View profile  
 More options Jun 25 2012, 12:40 pm
Newsgroups: microsoft.public.access.queries, microsoft.public.access.reports
From: "SriramNA" <M8R-ai1...@mailinator.com>
Date: Mon, 25 Jun 2012 22:10:38 +0530
Local: Mon, Jun 25 2012 12:40 pm
Subject: Re: SQL query with join on substring
I used the UDF to populate an additional column in the table, which I then
used for the join, worked very well.

Thanks for the help.

--
Sriram

See this knowledge base article, how you can build a functin you can use in
a query;
http://support.microsoft.com/kb/210537

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »