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

How to Query Partial Match from Two Tables

Relative Newbie w/ a stumper! Any help is appreciated. Thanks!

I have two tables that I have imported to access. I'd like to query between these two tables for records that have a shared last name (under a name field) in both tables.

It's a bit complicated because the name fields in the two tables are formatted differently, and sometimes inconsistently. For example: "ROGER D & BETTY JO COLE" in table 1, becomes "COLE ROGER D" in table 2.

I've seen lots of good information about joining the tables, but that seems more difficult here (I'd need to split up the name field data --difficult with middle initials and two part names [eg., Mary Jo] and then find a way to join the appropriate pieces).

Is there a better way to search for matches (or, possible matches), such as using a wild card search (eg., Like *COLE*) that would work on a whole sale basis?

THANKS!
Jul 13 '10 #1
4 14659
Denburt
1,356 Expert 1GB
Personally in this situation I would think that you could use a union query then you could search both tables for the information and start working on a cleanup solution.

This would have to be done in SQL view of a query, of course and would look something like:

Select [last name], "Table1" as Table1 From [Table one]
Union Select [last name], "Table2" as Table2 From [Table Two]
Jul 13 '10 #2
Thanks for the suggestion, Denburt. I'm not very familiar with SQL, so I'll have to do some googling before I know how well that will work --- again, one complication is that the name fields aren't neatly separated into first, middle, and last name fields.

I may be totally off-base here, but any idea why this doesn't work:

SELECT Table1.*, Table2.*, Table1.FullNameTb1
FROM Table1, Table2
WHERE (((Table1.FullNameTb1) Like "*[Table2].[FullNameTb2]*"));


Thanks again.
P.
Jul 13 '10 #3
Denburt
1,356 Expert 1GB
@Pat Rowe
Hmm that's an interesting approach. You can probably use that although you would need a slight adjustment.
Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.*, Table2.*, Table1.FullNameTb1
  2. FROM Table1, Table2
  3. WHERE (((Table1.FullNameTb1) Like "*" & [Table2].[FullNameTb2] & "*"));
The way you posted it you were looking for the text [Table2].[FullNameTb2] in the actual field and not the data in [Table2].[FullNameTb2].
Jul 13 '10 #4
Bytten
1
Thanks - that's a perfect solution to a look up I was trying to do. I just got rid of the need for about 50 individual 'like' queries
Feb 3 '12 #5

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

Similar topics

7
by: Jay | last post by:
Hi everyone ! I hope someone will be able to help me with this problem. I currently have several tables in MySQL database. Below is my table structures. (Data type for each fields are...
8
by: Rigga | last post by:
Hi, I am new to mysql and need help on how to join tables. I have a database which contains 4 tables, the main table contains information by date order and the other 3 contain data also in date...
1
by: Carl B Davis | last post by:
Help please!!! I am an intermediate access user that is getting my bottom kicked by what seems an easy problem to fix. I maintain an employee database at work. I have set up a query from two tables...
2
by: Christian Staffe | last post by:
Hi, I would like to check for a partial match between an input string and a regular expression using the Regex class in .NET. By partial match, I mean that the input string could not yet be...
1
by: Ike | last post by:
I have a simple query of joined tables that is failing to give me any rows of data (though, in checking by hand, it certainly should). Essentially, I am trying to return all rows from `ups` that...
2
by: Andrew Chalk | last post by:
I have a customer who wants to SELECT records based on a partial match in a text field. For example, in a list of telephone numbers they want to search for all records that contain the digits '777'...
1
by: Fendi Baba | last post by:
I need to perform a query against 3 tables, All the tables contain the fields, name and position and have the same foreig key which is project ID How can I do this and present this in a view? ...
4
by: wecka | last post by:
Hello All, Does any one know how to use the form filter in Access to provide partial match? When you choose to "form filter," all text boxes will convert to combo boxes where you can choose from...
1
by: Alex Chun | last post by:
How can I make a Query that combines tables, so that if table1 has records "apples", "pears" and table2 has records "apples", "cherries", the query result will be "apples", "pears", "cherries"? ...
16
by: vorlonfear | last post by:
I have been working on this for a while now and I wanted to see if someone could assist me. I have 2 tables each with 5 fields. 4 of the fields are 2 character strings, then the final field is the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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...

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.