realbasic-nug
[Top] [All Lists]

[Slightly OT] Praying to the SQL gods for some advice please....

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: [Slightly OT] Praying to the SQL gods for some advice please....
From: Tom Benson <tombenson at mac dot com>
Date: Mon, 31 May 2004 16:14:51 +1000
Delivered-to: realbasic-nug at lists dot realsoftware dot com
List-help: <mailto:realbasic-nug-request@lists.realsoftware.com?subject=help>
List-id: REALbasic NUG <realbasic-nug.lists.realsoftware.com>
List-post: <mailto:realbasic-nug@lists.realsoftware.com>
story is I've been given a MySQL database to build a front end for.... a bit of a strange layout.... here's where I hit the wall...

Customer DB is split into numerous tables:

CUSTOMERS
PEOPLE
COMPANIES
PHONENUMBERS
ADDRESSES

Basically the CUSTOMERS table is the key table, containing a column of values that all other tables key against. My problem is my client wants to be able to list all of his customers in a listbox, not just PEOPLE, and not just COMPANIES. And he wants this information alongside addresses and phonenumbers. To do this I'm going to have to conditionally join tables me thinks, and I'm running into difficulties.

Here's my basic query. It doesn't throw any errors, but send MySQL off on a trip to the moon and back... have left it running on a test data suite of 50 records for hours with no result....
I'm guessing my problem is using the OR clause in an inner join, but

SELECT * FROM customers, people, companies, addresses, phonenumbers WHERE customers.CustomerID=people.CustomerID OR customers.CustomerID=companies.CustomerID AND customers.CustomerID=addresses.CustomerID AND phonenumbers.CustomerID=customers.CustomerID

I know I can do this with multiple queries, but I also know that there is a way to do this, and would like to broaden my SQLskills a bit....

Cheers guru's,
Tom
_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>