473,396 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Partial string match two columns

11
I have two tables, each with a string that represents a model number. I need to create a table that shows each model next to the other. One table contains the full model number and the other table has varying numbers of characters missing. The match needed is to match part of the string in the full model to all of the string in the shorter string.

New to sql, have no idea what vba does. Have a fair understanding of access qbe. Version is 2013.

Thanks in advance.
Feb 26 '16 #1

✓ answered by NeoPa

Well, this could have been expressed a lot more clearly with a little effort, but if I understand the question correctly, and I'm really not certain of that, then the following SQL should represent a query that will return what you're after :
Expand|Select|Wrap|Line Numbers
  1. SELECT [A].[Column1]
  2.      , [b].[Column2]
  3. FROM   [TableA] AS [A]
  4.      , [TableB] AS [b]
  5. WHERE  ([A].[Column1] Like '*' & [b].[Column2] & '*')

14 3790
jimatqsi
1,271 Expert 1GB
Look at the INSTR() function. In
Expand|Select|Wrap|Line Numbers
  1. INSTR(A,B)
  2.  
returns a number greater than zero, then string B can be found in string A.

Jim
Feb 26 '16 #2
kdmrr
11
Thank you. I don't know anything about this but I'll try it later today and let you know how I do.
Feb 26 '16 #3
kdmrr
11
Jim, Thanks for your reply -I'm sorry, I just don't get it.

Here's a better example of what I'm trying to match

column1 Columm2
test cart
grapey est
afcarty ape

the desired result:

afcarty cart
grapey ape
test est

Thanks much
Feb 27 '16 #4
NeoPa
32,556 Expert Mod 16PB
Well, this could have been expressed a lot more clearly with a little effort, but if I understand the question correctly, and I'm really not certain of that, then the following SQL should represent a query that will return what you're after :
Expand|Select|Wrap|Line Numbers
  1. SELECT [A].[Column1]
  2.      , [b].[Column2]
  3. FROM   [TableA] AS [A]
  4.      , [TableB] AS [b]
  5. WHERE  ([A].[Column1] Like '*' & [b].[Column2] & '*')
Feb 28 '16 #5
kdmrr
11
NeoPa, Thanks for the response.
I tried the query and couldn't get it to work. Here's a better attempt to explain what I need.

I have two columns of part numbers from two different sources but they represent the same part. I'm trying to match them (there are hundreds and I'm trying to get them on the same row. Thanks

456abc abtest4
part23 3456abcdef
test trpart234y

Below would be the end result of the query

Partial_Model_Num Full_Model_Num
456abc 3456abcdef
test abtest4
part23 trpart234y
Feb 28 '16 #6
NeoPa
32,556 Expert Mod 16PB
So, with that requirement, why is what I already suggested not suitable?
Feb 28 '16 #7
kdmrr
11
That's a hopeful comment. I'll keep trying. The problem apparently is that I'm doing something wrong. Thanks
Feb 28 '16 #8
Rabbit
12,516 Expert Mod 8TB
It would help if you posted what you tried so we can tell you which part is incorrect
Feb 29 '16 #9
kdmrr
11
Rabbit, here it is
Expand|Select|Wrap|Line Numbers
  1. SELECT [One].[Partial_Model]
  2.      , [Two].[Full_Model]
  3. FROM  [tbl_One] AS [One]
  4.     , [tbl_Two] AS [Two]
  5. WHERE ([ONE].[Partial_Model] Like '*' & [Two].[Full_Model] & '*')
It returned a populated "partial_model" and null for "full_Model"

thx

Thanks
Feb 29 '16 #10
NeoPa
32,556 Expert Mod 16PB
It seems you have the Like back-to-front. The full should be like the partial but with optional extras. Not the other way around.
Feb 29 '16 #11
kdmrr
11
It worked!...at least on my little test tables. Here is the real sql and it doesn't work. It asks for a parameter value.
Expand|Select|Wrap|Line Numbers
  1. SELECT [Ahri].[Ahri_Mn_Trunc]
  2.      , [Gensco].[Gensco_Pn]
  3. FROM   [Ahri] AS [Ahri]
  4.      , [Gensco] AS [Gensco]
  5. WHERE  ([Gensco].[Gensco_Pn] Like '*' & [Ahri].[Ahri_Mn_Trunc] & '*');
Thanks again!
Feb 29 '16 #12
NeoPa
32,556 Expert Mod 16PB
Please remember to use the [CODE] tags when posting code. It's mandatory on this site.

As for your error, it would be very helpful if you'd include the prompt when you tell us that it prompts you for a value. This is likely to be something specific to your database, almost certainly a name spelled wrong, so we have no idea what the problem might be unless you include the information.
Mar 1 '16 #13
kdmrr
11
NeoPa,

THANK YOU! I found the problem and the query appears to work.
I was inaccurately typing a field name. I'll get my naming conventions cleaned up.

I don't understand what a [code] tag is. I did read the faq. Is the tag just the bracketed code that is not a reserved word or command?

Thanks again!
Mar 1 '16 #14
NeoPa
32,556 Expert Mod 16PB
Hi there. I've reset the Best Answer for you. It's very rarely appropriate to award this to the OP (yourself), and certainly not for this thread. Never mind that. I've sorted it for you.

[CODE] tags are what is used to format code in a way that is more easily readable. When typing out your post you can select a section of it that, includes the code, and then click on the button saying [CODE]. It will then put [CODE] & [/CODE] around that text and it will be formatted into a code block. For more options see BB Code.
Mar 1 '16 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mike | last post by:
Hello. Is it possible to specify a variable instead of a string as argument of string.match(). Example : myString.match(/abc/i) works but how to do this : pattern = "abc"
9
by: Ninan | last post by:
I have a map, with a composite key (a struct). I would like to delete all the elements with a partial key match and may be do other things in the future. The way I am doing it is as follows. I...
1
by: Stuart E. Wugalter | last post by:
Hiya Folks! I need some help with some string pattern matching. Let's say field1 (in Table1) contains the strings in question and it's data type is memo. I have a form that uses Table1 as its...
1
by: wlupton | last post by:
Hi All; My problem is getting information from an Access database using a partial string in VB6. The database consists of tables of information on motor vehicles including a 17 character VIN...
2
by: SQL Learner | last post by:
Hi All, I need to link two tables using partial word match. How can I write a SQL statement to do so? (I am using MS-Access.) Table One: 123 ABC Street 124 ABC Street 125 ABC Street
5
by: SQL Learner | last post by:
Hi Alex (Kuznetsov) and All, This is to follow up with my last post, "Link two tables using partial word match". How can I UPDATE table using partial word match? How can I write a SQL statement...
3
by: Edwin Smith | last post by:
Hello: I have the following code which works on a DataGridView binding source: private void textBox1_TextChanged(object sender, EventArgs e) { this.pATIENTSBindingSource.Position =...
1
by: tbucha3 | last post by:
I have two tables that I have to get information from to produce another table. Both tables come from separate resources, one has partial accounts with addresses and the other has complete account...
1
by: rnakawat | last post by:
I seem to have a problem using the preceding:: on substrings of the value. I'll try to explain with an example: Let's say I had a XML that look like: <Root> <Row> <Cell Name="Street"...
1
by: David Michaels | last post by:
I have a field called Photos in a database of information scraped from public records. This field contains the Photo information if one is available, however, if no photo is available, it inserts a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.