[thelist] Q on SQL 'ORDER BY' - part 3
jsWalter
jsWalter at torres.ws
Mon Apr 12 03:26:48 CDT 2004
OK, I'm back again.
Its late (or early!) and my brain is mush.
I have 2 tables, COMPANYT and CONTACTs
CONTACT has a foreign key to tie records to a particular record in COMPANY.
I'm trying to build a list of lists...
Sears - Sam
Sears - George
Sears - Sally
Wards - Henry
Wards - Sue
Kmart - Mike
Target
The query I have...
SELECT stations.st_id, stations.st_name,
contacts.con_id, contacts.con_name
FROM stations, contacts
WHERE stations.st_id = contacts.st_id
ORDER BY stations.st_name;
...returns every CONTACT tied to every COMPANY. Not what I'm looking for...
If I remove the WHERE clause, the CONTACTs are tied to their proper COMPANY,
but the "orphaned" COMPANYs do not show up.
Can any one enlighten me on this?
Thanks
Walter
More information about the thelist
mailing list