Solved

How use left outer join with 3 tables in ACCESS?

Posted on 2000-05-10
13
258 Views
Last Modified: 2010-04-04
I have 3 tables. One with customers. One with products and one which define categories of products. One product needn't a category. Now i will show with a select statement for all customers, to have all the products they have payed with the products categories or not.
I tried with left outer join and i could only put two tables(products,categories9 together. i couldn't get the customers information:

the code is like this~=:

SELECT c.name Cust, p.name, ca.name
FROM Products p LEFT OUTER JOIN Categories ca ON p.idc_R=ca.idc,
Products p LEFT OUTER JOIN Customers c ON p.idcust_R=c.idcust;

The error i get is JOIN are not supported. What i do wrong? Help me quickly, please!
0
Comment
Question by:bluecomet
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 15

Expert Comment

by:simonet
ID: 2797493
Rewrite it like this:

SELECT
   c.name as Cust,
   p.name,
   ca.name
FROM
   Products p
   LEFT OUTER JOIN Categories ca
      ON (p.idc_R=ca.idc)
   LEFT OUTER JOIN Customers c
      ON (p.idcust_R=c.idcust)



Yours,

Alex
0
 
LVL 2

Author Comment

by:bluecomet
ID: 2797570
Adjusted points from 200 to 225
0
 
LVL 2

Author Comment

by:bluecomet
ID: 2797571
Sorry, but that doesn't function.

it say that the join expression is not supported.

Please, need me!
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 2

Author Comment

by:bluecomet
ID: 2797579
hehehehe...

funny, no!

sorry,

i wanted write
please, need help and not please, need me!
0
 
LVL 15

Expert Comment

by:simonet
ID: 2797828
What database are you using?

Alex
0
 
LVL 2

Expert Comment

by:hhamster
ID: 2797836
But where's the payed information? That should be 4 tables together puted in the SELECT with JOINs. Or is it that I just don't understand enough English.

But for your example it should look like this one:

SELECT
  c.name Customer,
  ca.name Category
  p.name Product,
  FROM Products p
    LEFT OUTER JOIN Categories ca
      LEFT OUTER JOIN Customers c ON (here should be an ca, not p).idcust_R=c.idcust
    ON p.idc_R=ca.idc
....

For exact help we need exact inforamtion. Write the table structures for the Primary Keys and Foreign Keys.
0
 
LVL 3

Accepted Solution

by:
shenqw earned 225 total points
ID: 2798165
if you use MsAccess,then use follow sql:

SELECT c.name AS cust, p.name, ca.name
FROM Customers c  
     LEFT OUTER JOIN
     (
       Products p
       LEFT OUTER JOIN
       Categories ca
         ON (p.idc=ca.idc)
     )
       ON (p.idcust=c.idcust)



if use dbase or paradox,then user follow sql:

SELECT c.name AS cust, p.name, ca.name
FROM customer C
  LEFT OUTER JOIN Products p
    ON (p.idcust=c.idcust)
  LEFT OUTER JOIN Categories ca
    ON (p.idc=ca.idc)


if use Oracle,then user follow sql:

SELECT c.name AS cust, p.name, ca.name
FROM customer C,Products p,Categories ca
WHERE c.idcust=p.idcust(+)
  AND p.idc=ca.idc(+)
0
 
LVL 3

Expert Comment

by:shenqw
ID: 2798223
yor must change "p.idcust" into "p.idcust_R" in my answer!  :)

Good Luck!

shenqw
0
 
LVL 15

Expert Comment

by:simonet
ID: 2798503
shenqw, isn't not good ettiquete to answer a question like that if other experts are already working with you. You should post your comment and let the user decide. If you had been the first one in this thread, that would have been ok, but that's not the case, is it?

Watchout for that kinda behaviour, since it's not very appreciated 'round here by the other experts.

Alex
0
 
LVL 3

Expert Comment

by:shenqw
ID: 2799784
hi,simonet:
  Thx for your reminder.

  But i want say, I had write the anwer 5 hours before i post it(because Something is wrong with My ISP),Also i had tried all sql in my answer in MsAccess,DBase,Paradox, I know which is right and which is wrong in MsAccess, Because all above comments were wrong in MsAccess. So  I chose the Answer mode not Comment Mode.
0
 
LVL 15

Expert Comment

by:simonet
ID: 2971315
>Because all above comments were wrong in MsAccess

The asker never stated he's using MS Access, so you couldn't assume that and post an answer.

0
 
LVL 3

Expert Comment

by:shenqw
ID: 2990025
:)))

The title of The asker's question is "How use left outer join with 3 tables in ACCESS?"

shenqw
0
 
LVL 15

Expert Comment

by:simonet
ID: 2991157
OK... my bad!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 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