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

Comparing Combined Columns

Hi,

I have these two tables:

codes_together
----------------------------------------------
Prod_Name | CODE
----------------------------------------------
Cats BOB CAT
Wabbbits BUNNY & BUGS
HomeLine ELN + CURPWC + PAK03

and....

codes_separate
---------------------------------------------------------------------
ProductName | CODE_1 | CODE_2 | CODE_3
--------------------------------------------------------------------
Home Line ELN CURPWC PAK03
Cat BOB CAT null
Rabbit BUGS BUNNY null
I know that the Product Names can be sometimes off by a bit, so I am
trying to compare on the codes ONLY as I know they are accurate and
then tack on any of the Product names on the side and display only the
lines that MATCH together

Few things to take into consideration are:
* The codes_together.CODE can have any combination of the 3 codes. ie.
BUNNY can come before BUGS
* The codes_together.CODE will have either " " (empty space), "&" or
"+" between
So far, my method I have tried is to append all the code_1, code_2,
code_3 in 'codes_separate' together and then tried to compare it with
the codes_together.CODE column. (Not sure if this is the best method,
but the only one I know how... please suggest if you have a better way)
this is a start of the SQL command I have tried but gets syntax errors:

Select codes_together.Prod_name as [Product Name], codes_together.CODE
as [PCMS Codes]
from codes_together
INNER JOIN
(SELECT codes_split.ProductName, codes_split.CODE_1 & " " &
codes_split.CODE_2 & " " & codes_split.CODE_3
FROM codes_split)
ON codes_together.PCMS_CODE = codes.split.PCMScode;

Jun 26 '06 #1
1 1348
this is a start of the SQL command I have tried but gets syntax errors:

Select codes_together.Prod_name as [Product Name], codes_together.CODE
as [PCMS Codes]
from codes_together
INNER JOIN
(SELECT codes_split.ProductName, codes_split.CODE_1 & " " &
codes_split.CODE_2 & " " & codes_split.CODE_3
FROM codes_split)
ON codes_together.PCMS_CODE = codes.split.PCMScode;

Shouldn't the last period ( . ) be an underscore ( _ ) ?
and the bit where you join the three separate codes should include an AS
statement ( ...& codes_split.Code_3 AS PCMScode ).

Easier though is to first create a query that joins the three key-fields,
and save that query. Next, make your final query based on the table and the
query.

Furthermore, your naming conventions look a bit confusing to me. For
example, I cannot see the difference between Codes_separate and Codes_split.
A fine start would be to use prefixes such as tbl for table ans qry for
query. Allison Balter has a nice list with usable prefixes (google for 'tbl
qry prefix'). Makes your programming a lot easier. Especially when you need
to change something after a few months when you've forgotten what you did
earlier (I'm speaking from personal experience here:).
By the way, if you really want to learn the lot about Access, read this book
from Allison Balter start to finish. It covers all things from basic
relational database design to the final distribution of client-server
applications, and written for anyone between 'dummy' and 'pro-programmer',
and also works very fine as a reference guide when you need a specific bit
of information.

Bas Hartkamp.
<ja********@gmail.com> schreef in bericht
news:11**********************@p79g2000cwp.googlegr oups.com... Hi,

I have these two tables:

codes_together
----------------------------------------------
Prod_Name | CODE
----------------------------------------------
Cats BOB CAT
Wabbbits BUNNY & BUGS
HomeLine ELN + CURPWC + PAK03

and....

codes_separate
---------------------------------------------------------------------
ProductName | CODE_1 | CODE_2 | CODE_3
--------------------------------------------------------------------
Home Line ELN CURPWC PAK03
Cat BOB CAT null
Rabbit BUGS BUNNY null
I know that the Product Names can be sometimes off by a bit, so I am
trying to compare on the codes ONLY as I know they are accurate and
then tack on any of the Product names on the side and display only the
lines that MATCH together

Few things to take into consideration are:
* The codes_together.CODE can have any combination of the 3 codes. ie.
BUNNY can come before BUGS
* The codes_together.CODE will have either " " (empty space), "&" or
"+" between
So far, my method I have tried is to append all the code_1, code_2,
code_3 in 'codes_separate' together and then tried to compare it with
the codes_together.CODE column. (Not sure if this is the best method,
but the only one I know how... please suggest if you have a better way)
this is a start of the SQL command I have tried but gets syntax errors:

Select codes_together.Prod_name as [Product Name], codes_together.CODE
as [PCMS Codes]
from codes_together
INNER JOIN
(SELECT codes_split.ProductName, codes_split.CODE_1 & " " &
codes_split.CODE_2 & " " & codes_split.CODE_3
FROM codes_split)
ON codes_together.PCMS_CODE = codes.split.PCMScode;

Jun 27 '06 #2

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

Similar topics

6
by: teddysnips | last post by:
I have a table called WorkItem. It models a chunk of work done during a working day. It has two columns that I'm interested in: Start (smalldatetime) - the TIME the work block is begun...
88
by: William Krick | last post by:
I'm currently evaluating two implementations of a case insensitive string comparison function to replace the non-ANSI stricmp(). Both of the implementations below seem to work fine but I'm...
1
by: Will Chamberlain | last post by:
I just created an application that displays data from 2 sources in a datagrid. There are 2 repeaters nested in the datagrid (probably not the best idea). The whole purpose of this application is to...
4
by: Frank | last post by:
Hello, Developing an app where the user fills out a sometimes quite lengthy form of chkboxes, txtboxes, radbtns, etc. User responses are saved to a mySql db, which the user can later edit. When...
3
by: laredotornado | last post by:
Hi, I have two columns, both MySQL 4 DATETIME types ... TABLE1.depart_day TABLE2.depart_day and both are indexed. The problem is, all of TABLE1's dates have a time of midnight (e.g....
3
by: fezza1 | last post by:
Hello, I need some help, so thanks in advance. My database has 5 columns matching to particular years, i.e.,PrevYr, PrevYr1, PrevYr2, PrevYr3, PrevYr4. In a simple query, I've combined all...
8
by: Elfae | last post by:
I have searched high and low for a sample for this, and I just can't find any. Sorry for the length! Background Information The issue revolves around setting up a system-generated increase in...
3
by: erbrose | last post by:
Hello all! Newbie here, I've been tasked with a fairly intensive project here and my perl skills are still at a minimum so this post may eventually turn into a long one, but I am only going to ask...
0
by: Gabriel Genellina | last post by:
En Thu, 15 May 2008 06:02:29 -0300, Beema shafreen <beema.shafreen@gmail.comescribió: *three* columns? You menction only two of them. Do you have to syncrhonize both listings? That is,...
2
by: jumperbl | last post by:
I want to look at two columns lets say B1 to B8 and C1 to C8. I want to compare those ranges and if the columns don't match i want to color the cell. Here is how much i have figured out. ...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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...
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
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?

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.