Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Joining Three table using SQL

Posted on 2000-03-28
9
Medium Priority
?
229 Views
Last Modified: 2010-05-02
How to join three tables using SQL

joining loan and customer tables using customer_No
 
joining loan and payment tables using
loan_No
 
 Text1.text = Payment_No
 text2.text =loan_No
 Text3.text = Customer_No


 Private sub find_click()
 
  dtpayment.recordsource = "select * from payment where Payment_No = '" & text1.text & "'"
 
  dtpayment.refresh

  dtloan.recordsource = "select* from loan where Loan_No= '" & text2.text & "'"

  dtloan.refresh

 dtcustomer.recordsource = "select * from customer where customer_No = '" & text3.text & "'"

   dtcustomer.refresh

  end sub

 How this doesn't work

  please help

  abraham
0
Comment
Question by:abrahamling
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 10

Expert Comment

by:caraf_g
ID: 2663819
SELECT
FROM Payment INNER JOIN (Loan INNER JOIN CustomerTable ON Loan.[Customer No] = CustomerTable.[Customer No]) ON Payment.[Customer No] = Loan.[Customer No];
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2663836
What is your exact problem?
The only thing i can see is that you are querying 3 times the database and this could be done in 1 throw (see caraf_g's statement), and that in your 2nd statement there is no space between SELECT and *.
0
 
LVL 10

Accepted Solution

by:
caraf_g earned 200 total points
ID: 2663929
Tip: whenever you need to do complicated stuff like this in SQL you can go into Access, create a database with tables similar to your own and create a query with the handy drag & drop facilities provided. Finally, look at the sql view.

I made a small mistake in the query above in that I joined everything up on customer no.

Better:

SELECT
FROM (CustomerTable INNER JOIN Loan ON CustomerTable.[Customer No] = Loan.[Customer No]) INNER JOIN Payment ON Loan.[Loan No] = Payment.[Loan No];


And just use this as the record source for a single query.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:prax_n
ID: 2664859
If u could explain u r problem properly ...I could explain something .. i did not upderstand u r prob..
0
 
LVL 1

Expert Comment

by:simonstre
ID: 2665046
the inner joins are the best solution, but here's another one :-)


SELECT * FROM LOAN, PAYMENT, CUSTOMER WHERE [LOAN].LOAN_NO = [PAYMENT].LOAN_NO
  AND [CUSTOMER].CUSTOMER_NO =   [LOAN].CUSTOMER_NO
0
 

Author Comment

by:abrahamling
ID: 2665443
Thanks you caraf_g's

 
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2668176
Thank you? So why did you give me a "C"?

If my answer was in any way unsatisfactory, I would have preferred it if you had asked further questions, and I would have been happy to resolve outstanding problems with you. A "C" looks bad in my profile... :-(
0
 

Author Comment

by:abrahamling
ID: 2672538
Caraf_q, thanks you for your help,

  I really mean it. sorry for giving u

  a "C". but i promise, next time, i

 will definitely give a excellent Grade.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2672567
Hey, no problem! Thanks for clearing that up ;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question