473,399 Members | 4,192 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,399 software developers and data experts.

Merging result from three queries

didajosh
I have three queries fetching data like:
Query 1
ID---NAME-POSITION
01---Sam---001
01---Sam---002
02---Joe---002
03---Zach--003
-----------------------------------------------
Query 2
ID---EARN_CODE-----GROSS-----HOURS
01----AA-----------$10-------10.00
01----BB-----------$10-------10.00
01----CC-----------$10-------10.00
02----AA-----------$10-------10.00
02----CC-----------$10-------10.00
03----AA-----------$10-------10.00

-------------------------------------------------
Query 3
ID-----HIRE_DATE-----PLAN---EMPLOYER_AMT---EMPLOYEE_AMT
01-----01012009---DENTAL------$20----------$30
01-----01012009---HOUSE-------$20----------$30
01-----01012009---HEALTH------$200----------$300
02-----01012009---DENTAL------$20----------$30
02-----01012009---HOUSE-------$20----------$30
02-----01012009---HEALTH------$200----------$300
03-----01012009---DENTAL------$20----------$30
03-----01012009---HOUSE-------$20----------$30
03-----01012009---HEALTH------$200----------$300
-------------------------------------------------

When I run a select query on these three queries
with common ID's
------------------------------------
select ID,NAME,POSITION,EARN_CODE,GROSS,HOURS,HIRE_DATE,P LAN,EMPLOYER_AMT,EMPLOYEE_AMT
from query1,query2,query3
where
query1.id=query2.id
and
query1.id=query3.id
---------------------------------------

01-Sam-001-AA-$10-10.00-01012009-DENTAL-$20-$30
01-Sam-001-AA-$10-10.00-01012009-HOUSE-$20-$30
01-Sam-001-AA-$10-10.00-01012009-HEALTH-$20-$30
01-Sam-001-BB-$10-10.00-01012009-DENTAL-$20-$30
01-Sam-001-BB-$10-10.00-01012009-HOUSE-$20-$30
01-Sam-001-BB-$10-10.00-01012009-HEALTH-$20-$30
01-Sam-001-CC-$10-10.00-01012009-DENTAL-$20-$30
01-Sam-001-CC-$10-10.00-01012009-HOUSE-$20-$30
01-Sam-001-CC-$10-10.00-01012009-HEALTH-$20-$30

AND SO ON....

Is there some way I can stop the repetition of these values.

Any help would be great.
Apr 14 '11 #1
3 1681
Rabbit
12,516 Expert Mod 8TB
There's no repetition. Each record is unique. Without knowing your intent, there's not much we can help with.
Apr 15 '11 #2
Hi,
thank you for replying.
Here is he kind of result I am looking for:

01-Sam-001-AA-$10-10.00-01012009-DENTAL-$20-$30
01-Sam-001-BB-$10-10.00-01012009-HOUSE-$20-$30
01-Sam-001-CC-$10-10.00-01012009-HEALTH-$20-$30

HOw can I get this kind of result.
Apr 15 '11 #3
Rabbit
12,516 Expert Mod 8TB
You don't have the necessary fields to link your tables together to produce that result. How is Query 2 supposed to know that it should only use position 001 and not position 002? There's no way for it to know that unless you put position number in query 2. How is Query 3 supposed to know that the earn_codes map in that manner to plan? There's no way for it to know that unless you put earn_code in query 3.

Your structure can't support the query that you want to run because you are missing the required links between your recordsets.
Apr 15 '11 #4

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

Similar topics

2
by: Satvic | last post by:
Hi all, Sorry for HTML, there is a lot of code & comments I tried to create a stored procedure from 3 queries .. to reduce # of times DB gets access from 1 asp page. The result procedure only...
3
by: KS | last post by:
I am passing the following three queries in a string in VS.NET C# class string sql = "SELECT A FROM TABLEA; SELECT B FROM TABLEB; SELECT C FROM TABLEC;"; OdbcAdapter thisAdapter = new...
2
by: rockyptc | last post by:
greetings. first, i apologize for asking an old question. it appears that i'm looking for a solution that was already given but it don't seem to fit my scenario. so thanks for putting up with me. ...
12
by: Susan Bricker | last post by:
For those of you who have been following my posts - they all pertain to a Dog Competition Organization's Database. There are three classes that the dogs can participate: NOVICE, OPEN, and...
2
by: jim_geissman | last post by:
I'm cleaning data which involves updating ~12 million rows with three different models, progressively. First clean values using the model with finest granularity, then the remainder with the next...
3
by: coder | last post by:
I am new to programming in PHP however, this should be a pretty straight forward answer. I have three queries that I am pulling for a content form page. 1) The Author List 2) The Content Page...
2
by: sjlung | last post by:
I have set up queries in access that make tables and then append them to each other. Unfortunately the resulting table after three seperate tables are appended does not comprise of all the entries...
4
by: mbatestblrock | last post by:
Hello access gurus! I am need of some assitance. I am finally reaching the end or a grueling process. I say grueling, and I am sure its a snap for all of you, which is why I am hoping you all can...
0
by: vksace | last post by:
select ob.amount from BRDB_SU_OPENING_BALANCE ob where ob.BRANCH_ACCOUNTING_CODE=654321 AND ob.STOCK_UNIT='UT1' AND ob.TRADING_PERIOD=101 AND ob.BALANCE_PERIOD=1 AND ob.PROD_ID=654 select...
1
by: kigoobe | last post by:
Hi friends, I'm having three queries that works perfectly ... SELECT ib.id as id, ib.titre as title, ib.date_expire as date_fin, ib.created_at as date_creation, eb.content as content, '' FROM...
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: 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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.