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

Performing a join on a calulcated field

Hi all, I have the following problem:
Query1
Code Trimmed Code
AB123 AB
AC123 AC

Table2
AB Europe
AC USA
AD Japan

Desired Output
Code Trimmed Code Region
AB123 AB Europe
AC123 AC USA
I need to join query1 and table2, but the key is a calculated field,
the field "trimmed code" which retrieves the first 2 characters of the
field "code". How can I do a join on a calculated field?

The only solution I can think of is to convert query1 into a table,
and take it from there, but it's clearly not an efficient solution.

Any help would be greatly appreciated!

PS I know this structure of the data sucks: I didn't decide it , I'm
just stuck with it :(
Jan 7 '08 #1
2 1029

<my********@googlemail.comwrote in message
news:91**********************************@i29g2000 prf.googlegroups.com...
Hi all, I have the following problem:
Query1
Code Trimmed Code
AB123 AB
AC123 AC

Table2
AB Europe
AC USA
AD Japan

Desired Output
Code Trimmed Code Region
AB123 AB Europe
AC123 AC USA
I need to join query1 and table2, but the key is a calculated field,
the field "trimmed code" which retrieves the first 2 characters of the
field "code". How can I do a join on a calculated field?

The only solution I can think of is to convert query1 into a table,
and take it from there, but it's clearly not an efficient solution.

Any help would be greatly appreciated!

PS I know this structure of the data sucks: I didn't decide it , I'm
just stuck with it :(
If you can't fix the table for query 1 by adding a region field, add a join
table with Code and Region fields that would look like the output from
query1.
Jan 7 '08 #2
"my********@googlemail.com" <my********@googlemail.comwrote in
news:91**********************************@i29g2000 prf.googlegroups.com:
Hi all, I have the following problem:

Query1
Code Trimmed Code
AB123 AB
AC123 AC

Table2
AB Europe
AC USA
AD Japan

Desired Output
Code Trimmed Code Region
AB123 AB Europe
AC123 AC USA
I need to join query1 and table2, but the key is a calculated field,
the field "trimmed code" which retrieves the first 2 characters of the
field "code". How can I do a join on a calculated field?
I would try:

SELECT Q1.Code, T2.Region
FROM Query1 AS Q1
LEFT JOIN Table2 AS T2
ON Left(Q1.[Trimmed Code],2) = T2.[code]

OR Maybe
T2.[code] LIKE Left(Q1.[Trimmed Code],2) & '*'

In the menu for the query builder click the drop down in the upper left
corner and choose the SQL view to write this. Access's query-builder-
wizard-type-dialog is not great for anything but the very simplest of
JOINs.

Jan 7 '08 #3

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

Similar topics

0
by: Preston Landers | last post by:
Hello all. I am trying to write a query that "just" switches some data around so it is shown in a slightly different format. I am already able to do what I want in Oracle 8i, but I am having...
2
by: Preston Landers | last post by:
Hello all. I am trying to write a query that "just" switches some data around so it is shown in a slightly different format. I am already able to do what I want in Oracle 8i, but I am having...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
8
by: Sham | last post by:
I am trying to perform the following query on a table that has been indexed using Full Text Search. The table contains multiple columns than have been indexed. (Below, all xml columns are...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.