473,791 Members | 3,122 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Joining fields in queries using partial values

Question about joins in queries. I have 2 tables with a field called
"ID".

Table 1
Rec1 = Jan12FredFlints tone
Rec2 = Feb01WilmaRubbl e

Table 2
Rec1 = Jan12BarneyRubb le
Rec2 = Mar03SamSlate

I'm trying to write a query that says show me all values where
Left([table 1].[id],5) = Left([table2].[id],5). I don't know how to
enter this into a query window. Do I need to join the tables somehow?
I tried just adding both tables without joining and entering the
parameters like I have above, but system froze. I have 30,000 records
in each table if that matters.

I don't want to create a new field that just has the left 5 of the ID
field if it's not needed.

Thanks,
D

Sep 6 '06 #1
12 5568
This design is serious bad news. You can't create joins on partial
matches. You either have a match or you don't. Split the values in a
query, then try joining the resulting queries.

Sep 6 '06 #2
On 6 Sep 2006 12:24:49 -0700, "ve***@aol. com" <ve***@aol.comw rote:

Sure that works. Here is an example using the Northwind sample
database:
SELECT Customers.Custo merID, Employees.Emplo yeeID,
Customers.Conta ctName, Employees.First Name, Employees.LastN ame
FROM Customers, Employees
WHERE ((Left$([ContactName],5)=Left$([FirstName],5)));

I agree with PietLinden: you have a seriously problematic db design,
and you will have more problems down the road if you don't redesign.

-Tom.

>Question about joins in queries. I have 2 tables with a field called
"ID".

Table 1
Rec1 = Jan12FredFlints tone
Rec2 = Feb01WilmaRubbl e

Table 2
Rec1 = Jan12BarneyRubb le
Rec2 = Mar03SamSlate

I'm trying to write a query that says show me all values where
Left([table 1].[id],5) = Left([table2].[id],5). I don't know how to
enter this into a query window. Do I need to join the tables somehow?
I tried just adding both tables without joining and entering the
parameters like I have above, but system froze. I have 30,000 records
in each table if that matters.

I don't want to create a new field that just has the left 5 of the ID
field if it's not needed.

Thanks,
D
Sep 6 '06 #3
Great, looks like that worked. Thanks Tom! Guess I wrote it
incorrectly. Thanks for mention on DB design. They actually are split
out and a combo of 4 fields. I won't bore anyone with why they are
combined here but this should solve my current issue nonetheless!

Tom van Stiphout wrote:
On 6 Sep 2006 12:24:49 -0700, "ve***@aol. com" <ve***@aol.comw rote:

Sure that works. Here is an example using the Northwind sample
database:
SELECT Customers.Custo merID, Employees.Emplo yeeID,
Customers.Conta ctName, Employees.First Name, Employees.LastN ame
FROM Customers, Employees
WHERE ((Left$([ContactName],5)=Left$([FirstName],5)));

I agree with PietLinden: you have a seriously problematic db design,
and you will have more problems down the road if you don't redesign.

-Tom.

Question about joins in queries. I have 2 tables with a field called
"ID".

Table 1
Rec1 = Jan12FredFlints tone
Rec2 = Feb01WilmaRubbl e

Table 2
Rec1 = Jan12BarneyRubb le
Rec2 = Mar03SamSlate

I'm trying to write a query that says show me all values where
Left([table 1].[id],5) = Left([table2].[id],5). I don't know how to
enter this into a query window. Do I need to join the tables somehow?
I tried just adding both tables without joining and entering the
parameters like I have above, but system froze. I have 30,000 records
in each table if that matters.

I don't want to create a new field that just has the left 5 of the ID
field if it's not needed.

Thanks,
D
Sep 6 '06 #4
Spoke too soon. I wrote my question wrong I think. I'm trying to show
all the values that are in one table but NOT in the other.

So the Left(table1) = Left(table2) does work if I was trying to show
the equal values but if I substitute <for = that doesn't work. So in
my original example, from Table 1 I'd expect to only see Rec2 because
the left 5 of that record is not in Table 2.

ve***@aol.com wrote:
Great, looks like that worked. Thanks Tom! Guess I wrote it
incorrectly. Thanks for mention on DB design. They actually are split
out and a combo of 4 fields. I won't bore anyone with why they are
combined here but this should solve my current issue nonetheless!

Tom van Stiphout wrote:
On 6 Sep 2006 12:24:49 -0700, "ve***@aol. com" <ve***@aol.comw rote:

Sure that works. Here is an example using the Northwind sample
database:
SELECT Customers.Custo merID, Employees.Emplo yeeID,
Customers.Conta ctName, Employees.First Name, Employees.LastN ame
FROM Customers, Employees
WHERE ((Left$([ContactName],5)=Left$([FirstName],5)));

I agree with PietLinden: you have a seriously problematic db design,
and you will have more problems down the road if you don't redesign.

-Tom.

>Question about joins in queries. I have 2 tables with a field called
>"ID".
>
>Table 1
>Rec1 = Jan12FredFlints tone
>Rec2 = Feb01WilmaRubbl e
>
>Table 2
>Rec1 = Jan12BarneyRubb le
>Rec2 = Mar03SamSlate
>
>I'm trying to write a query that says show me all values where
>Left([table 1].[id],5) = Left([table2].[id],5). I don't know how to
>enter this into a query window. Do I need to join the tables somehow?
>I tried just adding both tables without joining and entering the
>parameters like I have above, but system froze. I have 30,000 records
>in each table if that matters.
>
>I don't want to create a new field that just has the left 5 of the ID
>field if it's not needed.
>
>Thanks,
>D
Sep 6 '06 #5

ve***@aol.com wrote:
Spoke too soon. I wrote my question wrong I think. I'm trying to show
all the values that are in one table but NOT in the other.
create an outer join - use the Find Unmatched query wizard.

Sep 6 '06 #6
Hate to be a nuisance but I do have an idea how to do the unmatched,
but not with a partial field. Can't use "Is Null" because I only want
to match partial.
pietlin...@hotm ail.com wrote:
ve***@aol.com wrote:
Spoke too soon. I wrote my question wrong I think. I'm trying to show
all the values that are in one table but NOT in the other.

create an outer join - use the Find Unmatched query wizard.
Sep 6 '06 #7
You would have to base in on the query Tom gave you, or something like
it. (I bet normalization is sounding pretty good right about now...)

SELECT Customers.Custo merID, Employees.Emplo yeeID,
Customers.Conta ctName, Employees.First Name, Employees.LastN ame
FROM Customers, Employees
WHERE ((Left$([ContactName],5)=Left$([FirstName],5)));
Then you'd base your Find Unmatched query on a query like the above

Sep 6 '06 #8
You would have to base in on the query Tom gave you, or something like
it. (I bet normalization is sounding pretty good right about now...)

SELECT Customers.Custo merID, Employees.Emplo yeeID,
Customers.Conta ctName, Employees.First Name, Employees.LastN ame
FROM Customers, Employees
WHERE ((Left$([ContactName],5)=Left$([FirstName],5)));
Then you'd base your Find Unmatched query on a query like the above

Sep 6 '06 #9
pi********@hotm ail.com wrote in
news:11******** **************@ i3g2000cwc.goog legroups.com:
This design is serious bad news. You can't create joins on
partial matches. You either have a match or you don't. Split the
values in a query, then try joining the resulting queries.
Of course you can do non-equi joins. You just can't do them in the
QBE.

But it's non-optimal, as the join can't use indexes. The examples
are clearly cases where the parts of the single value should be
stored in multiple fields.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 6 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1847
by: Gianfranco | last post by:
Hi I got a problem with 2 tables. I have a table, say A, with x records, coming from a make table query and a table, say B, with y records, coming from another make table query. I need to join and link the 2 tables, so that the first record of A is associated with the fist record of B, the second record of A is associated (I mean,in the same row) with the second record of B and so on...until the last row of A (where x<y). I tried to...
6
5271
by: AAVF | last post by:
Hi We have a problem with a query. An Access database links via ODBC to a UNIX server. To speed things, we use the ODBC to load the relevant tables to the local PC that runs Access so that all querying is done locally. One of the reports we run allows the user to list all invoices within a period. They are also allowed to select a customer code and a product set on
5
10882
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the new database. For instance, her old database has a table with Band Info in it. Her new database also has a table with Band Info in it but slightly different. I was wondering if there was an easy way to compare the fields from similar tables in...
3
10668
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays the record's ID number. When I add the source table to the query it makes several records...
2
1560
by: Dan Cook | last post by:
Ok... here's the scoop... I've got an unbound form with Serial Number, Building, and Room... all this is in tableA... Now I've got the form setup with building, room and serial number as combo fields... I've got it so that when you click the dropdown on Building it queries the table for all buildings, then the one for room queries for all the rooms in the picked building, and the serial number drop down queries on building or building...
3
1439
by: VMI | last post by:
I'm currently using the dataAdapter.Fill method to fill my dataset with data from an Access DB. My dataset will contain a table with three fields from Access. In my datagrid (for user interaction), I need to join the data from these 3 cols into a temporary datacolumn. I can't add this additional column in the Access table because I'll be duplicating data so I was thinking of creating a datacolumn in runtime and looping through the filled...
7
2028
by: Dan | last post by:
(Using Classic ASP & MS Access) I have a page that has 120 fields on it (mostly checkboxes). I cannot split this into smaller pages. So what i want to do is write a class that handles this. in the code it would be something like: Set thisForm = new classBigForm
5
1700
by: mike | last post by:
Question. I have a new table that I am adding to a script that I wrote. This table has 3 fields, the first 2 fields are used in the on statement as being = other fields in the script. The first field always has data in it, but the 2nd field is sometimes null. So my problem is if both fields have data in them and they both match to the data in the fields that I am linking them to, then it returns
9
2645
by: markla | last post by:
Hi, I have an EDM model, which I'm rendering using DynamicData pages. I need to add a derived/calculated field. For example, in a "Person" entity, I have LastName and FirstName. I need to add a derived field FullName (being LastName + ", " + FirstName) I have tried adding the FullName field to Person's EDM partial class, and
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10201
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10147
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9023
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6770
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4100
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.