473,388 Members | 1,209 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,388 software developers and data experts.

How Do I Link Two Tables with Only a Partial Match

6
one table shows 123456 in ID the other table shows 123456/1

I want to return records where these two fields match but I don't want to specify the actual number, just where these fields match, even if it is partially. Help !
Oct 6 '11 #1
15 22572
Oralloy
988 Expert 512MB
Suzemt,

In what context are you working? Access? Or through ODBC?

Cheers,
Oralloy
Oct 6 '11 #2
Rabbit
12,516 Expert Mod 8TB
You can use the LIKE predicate with wildcards.
Oct 6 '11 #3
Suzemt
6
I am using Access. I want to retrieve records that match the numbers as shown above. The field is the primary key.
Oct 6 '11 #4
Rabbit
12,516 Expert Mod 8TB
I refer you back to post 3.
Oct 6 '11 #5
JAGster
26
Suzemt,

For exact matches you just need to create a select query with a join on the two fields you want matched. Try the query wizard. For partial matches, it depends on what you want to match. Rabbit is correct that you need to use the LIKE predicate with wildcards. If you will respond with exactly what type of partial match i.e. field in table2 must start with all characters in ID field in table1 and can have extra characters following, or field in table2 must have all characters in ID field in table1 and can have characters preceding and/or following. Then we can give you more specific help on how to create your query.

Regards
JAGster
Oct 6 '11 #6
Suzemt
6
I am looking for, if the 7 characters in table one, match the first 7 characters in table 2 (table 2 having more characters)then consider that a match.
Oct 6 '11 #7
JAGster
26
In the select query's criteria row, in the table2 field that needs to partially match, enter the following - Like [Table1.ID] & "*". Just be sure to replace "Table1.ID" with the acutal table and field names.
Oct 6 '11 #8
NeoPa
32,556 Expert Mod 16PB
I would suggest :
Expand|Select|Wrap|Line Numbers
  1. SELECT tbl1.*
  2.      , tbl2.*
  3. FROM   [tbl1]
  4.        INNER JOIN
  5.        [tbl2]
  6.   ON   tbl2.ID Like tbl1.ID & '/*'
@Suzemt
A little more thought given to expressing what you actually require help with would be appreciated. Working with so very little information provided is unnecessarily difficult.
Oct 6 '11 #9
Suzemt
6
OK. I have two tables. In table 1 the ID field contains a 7 digit number. In table 2 the ID field contains the same 7 digit number with /1 added. These fields are the primary key fields. JAGsters suggestion works great if I use another field as the primary key.
Oct 7 '11 #10
NeoPa
32,556 Expert Mod 16PB
You don't even comment on my suggestion in post #9. It would be nice to know if it worked or failed. That doesn't seem to be asking too much.
Oct 7 '11 #11
Suzemt
6
Sorry! no rudeness intended. I was looking for the more simple approach of just a select query without SQL. I may need to pass this on to less adept Access users. All advice is most gratefully accepted.
Oct 7 '11 #12
Suzemt
6
By passing on to less adept users I was referring to the data base I have, not my query!!!!
Oct 7 '11 #13
JAGster
26
Suzmet, The select query with the statement in the criteria field is the simplest way I know of for doing what you want.

The statement for the criteria field is - Like [Table1.ID] & "*"

You just have to replace "Table1.ID" with the name of your first table and the name of the ID field.

Here is a screenshot of a sample query (mouseover it to expand the image)



Let me know if this works or if you have other questions.
Regards, JAGster
Oct 7 '11 #14
NeoPa
32,556 Expert Mod 16PB
Suzemt:
Sorry! no rudeness intended.
I can accept that Suze. I appreciate that different people find different things to be outside their comfort zones. That's no problem if you choose to use JAGster's offering instead. I was just hoping for some feedback as to whether or not it worked when you tested it (I assume you tested it). It may also help others who are looking for solutions to similar problems to find a post explaining whether or not any particular suggestion worked.
Oct 7 '11 #15
Such an elegantly simple fix - thanks JAGster!
Mar 18 '19 #16

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

Similar topics

0
by: Mark | last post by:
Hi all, I have 2 files containing Id numbers and surnames (these files essentially contain the same data) I want to select distinct() and join on id number to return a recordset containing every...
21
by: nospam | last post by:
Ok, I asked this question before and I also looked at the book "First Look at ASP.NET 2.0" I also read Paul wilson's web page explanation. HOWEVER...... The book and that web page talks about...
0
by: Jon Slaughter | last post by:
struct NullClass { void Null() { } }; template <unsigned int i, typename T> struct Node { enum {I = i}; typedef T Class; };
4
by: Erik Wikström | last post by:
In school (no I will not ask you to do my schoolwork for me) we talked about policy-based design and got an assignment where we got the a code- fragment from a stack-implementation. The idea with...
2
by: Larry | last post by:
I have the following code attached to a search button on a form that runs a query. It works great, except that the search for Last Name only returns exact matches. It is even case sensitive....
2
by: B Moor | last post by:
I have a database with 100,000's records, each with a unique reference, eg A123BNK456 I would like to generate a search facility whereby we can choose an exact match or partial match, where the...
12
by: veaux | last post by:
Question about joins in queries. I have 2 tables with a field called "ID". Table 1 Rec1 = Jan12FredFlintstone Rec2 = Feb01WilmaRubble Table 2 Rec1 = Jan12BarneyRubble Rec2 = Mar03SamSlate
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 =...
3
by: gyap88 | last post by:
I m currently creating a search engine for my database using visual basic 2005. I want to my program to return search result even if the user only enter PARTIAL matches. Dim city As String...
1
by: chungiemo | last post by:
Hi thought I would do another thread as this one is a bit different from the previous problem I am looking for a solution to the relating problem Comparing 2 access databases with 2 tables,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.