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

Help needed for a Query

114 100+
Hello everybody, well i have 3 tables created in my access db i.e tblClient, tblProject & tblPayment. The main table is tblClient where Client information is stored with ClientID as the Primary key. Now the other two tables are linked with Client Table using ClientID as the foreign key. Now the situation is that for each client there can be many projects and the payments can also be made in any numbers (times). So, now i need to have a joined query showing the client information, project information & payment information at one go. If the client has 3 projects in hand and made payment only once then the query result should in the following pattern.

[HTML]
CLIENTID PROJECT PAYMENT
1 abcdefghi 1000
1 ihgfedcba
1 sdhfdjfdjff [/HTML]
Please give me a good query.
Oct 13 '07 #1
7 1314
nico5038
3,080 Expert 2GB
For showing "optional" information you need to use the so-called "OUTER JOIN".
Just connect the PK with the FK in the other table and double-click the connectionline. Now chose 2 or 3 to make one of the tables "always show up".
In this construction however you need to realize that two payments will show the client and the project twice.
As I assume that payments are "project related", I would advise to link Client to Project using the ClientID and Project to Payment using the ProjectID, else you could get multiple payments of a client from different projects linked to one project....

Nic;o)
Oct 13 '07 #2
Scott Price
1,384 Expert 1GB
You have inadvertently posted your question in the Articles section. I have moved it across for you to the main Forum.

MODERATOR
Oct 13 '07 #3
NeoPa
32,556 Expert Mod 16PB
Very interesting question.
Unfortunately (as Nico has explained in his post) it is not possible to have two independent lists appearing in the same query without duplication. If they are logically linked (as he suggested), that would be another matter, but independent lists cannot be worked that way in SQL (You could write fiddly code to do it but it really would be just that - fiddly).
Oct 13 '07 #4
raaman rai
114 100+
Ya practically the tables doesnot have the normalization norms followed. But please note that the clients make payment for 2 or 3 projects at one go and this payment cannot be updated against each of these projects as to avoid duplication. therefore, its mandatory for me to make two tables i.e tblProject & tblPayment to keep the payment and project details seperately. Thus the essence has been found to find out a solution in this case. Please lemme know more



For showing "optional" information you need to use the so-called "OUTER JOIN".
Just connect the PK with the FK in the other table and double-click the connectionline. Now chose 2 or 3 to make one of the tables "always show up".
In this construction however you need to realize that two payments will show the client and the project twice.
As I assume that payments are "project related", I would advise to link Client to Project using the ClientID and Project to Payment using the ProjectID, else you could get multiple payments of a client from different projects linked to one project....

Nic;o)
Oct 15 '07 #5
raaman rai
114 100+
Ya practically the tables doesnot have the normalization norms followed. But please note that the clients make payment for 2 or 3 projects at one go and this payment cannot be updated against each of these projects as to avoid duplication. therefore, its mandatory for me to make two tables i.e tblProject & tblPayment to keep the payment and project details seperately. Thus the essence has been found to find out a solution in this case. Please lemme know more



Very interesting question.
Unfortunately (as Nico has explained in his post) it is not possible to have two independent lists appearing in the same query without duplication. If they are logically linked (as he suggested), that would be another matter, but independent lists cannot be worked that way in SQL (You could write fiddly code to do it but it really would be just that - fiddly).
Oct 15 '07 #6
NeoPa
32,556 Expert Mod 16PB
Raaman,

Perhaps you didn't understand what I was saying.
There is no way (certainly that I know of) to produce what you need in basic SQL.
It is possible to create a table, which could later drive a report, by processing through the recordsets in code. This would be very fiddly and I wouldn't begin to try to take you through that at this stage without some indication that you understand the principles of what's involved and are ready to do the work necessary. The code will use concepts outlined in the article Basic DAO recordset loop using two recordsets. Before we proceed you need to show that this is understood and you're ready to continue working at this level. Does that make sense?
Oct 15 '07 #7
nico5038
3,080 Expert 2GB
One solution I see is to add a new table "tblProjectPayment" for recording what (part of) a payment is assigned to a project.
Another solution would be to record the TotalPrice in the project table and add a field "FullyPayed". This will allow to record per Client the Amount of Fully payed projects and the Amount payed in total. The difference would be the partial remainder for the next project....

Still a bit odd, as in general Invoices are used for payments and these will have the Requested Payment. There normally a "date payed" is used to indicate no reminder has to be sent.....

Nic;o)
Oct 15 '07 #8

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

Similar topics

1
by: Erich Trowbridge | last post by:
Has anybody seen this tool? It is awesome. check out http://vw.vermeer.org/ . It's a php front end for large-scale syslog deployments. It makes managing syslog in large networks a snap. The idea...
1
by: Ralph Freshour | last post by:
I'm not sure the follow multiple table query is the right way to do what I need to do although it seems to be working: $php_SQL = "SELECT * ". "FROM basics, personal, photos ". "WHERE...
4
by: Surendra | last post by:
I have this query that I need to use in an Update statement to populate a field in the table by the value of Sq ---------------------------------------------------------------------------- Inline...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
6
by: paii | last post by:
I have a table that stores job milestone dates. The 2 milestones I am interested in are "Ship Date" TypeID 1 and "Revised Ship Date" TypeID 18. All jobs have TypeID 1 only some jobs have TypeID 18....
5
by: Alicia | last post by:
Hello everyone based on the data, I created a union query which produces this. SELECT ,,, 0 As ClosedCount FROM UNION SELECT ,, 0 AS OpenedCount, FROM ORDER BY , ;
7
by: Aaron | last post by:
Complete code follows. I am new to .NET programming (and programming in general) and I am having a difficult time understanding how to fill a variable in one sub, and then access it from...
6
by: Takeadoe | last post by:
Dear NG, Can someone assist me with writing the little code that is needed to run an update table query each time the database is opened? From what I've been able to glean from this group, the...
0
by: Chuck36963 | last post by:
Hi all, I've been working on a listing problem and I can't figure out how to work it out. I have looked far and wide on the web to find answers, but I'd like other peoples input on my project in...
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:
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: 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
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
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.