Mailing List
Home
MySQL General - General MySQL discussion
MaxDB - Everything about MaxDB, formerly known as SAP DB
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
ODBC - ODBC with the MySQL Connector/ODBC driver
Perl - Perl support for MySQL with DBI and DBD::mysql
MySQL++ - Programming with the C++ API to MySQL
Subjects
mysql openssl Question
mysql:it 's a db not a dbms how it 's possible?!
Does the binary log enabling affect the MySQL performances?
Strange behavior, Table Level Permission
FULLTEXT query format question
Preventing Duplicate Entries
Comparing and writing out BLOBS
Executing MySQL Commands From Within C Program
Can 't access mysql after kernel upgrade
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Downgrade Mysql from 4 to 3 23
MySQL Cluster Software
mysql test 4 1 fails with the gis test
ERROR 2002: Can 't connect to local MySQL server through socket
Getting Identity after INSERT
Update one field with more fields from another table
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
mysql have same function mthod as Oracle decode()
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Help with a tough query

Help with a tough query

2004-03-15       - By Brent Baisley

 Back
Reply:     1     2     3     4     5     6     7     8  

I didn 't think this was too hard when I first created it, but now that
I 'm loading test data it 's not working as expected.

The core of the query is three tables: Event, Contact, and Regarding.
There can be zero or more Contacts for each event and zero or more
"Regardings " for each event. There are also 7 left joins I do to get
other linked data, but that 's working fine.

So, the question is, how do I get a list of events with possible
multiple contacts and multiple regardings?

The problem I run into with my current query is that it fails when
there are no contacts or regardings for an event. Is this possible in a
single query? Here is a short version of my current query.
SELECT DISTINCT EventID, Contact.Name, Regarding.Name
FROM Events, Contacts, Regarding
WHERE Events.EventID=Contacts.EventID AND
Events.EventID=Regadings.EventID

It is possible that I can make the Contacts database a one to many
relation since 99% of the time there will be an associated contact
record. I can make a "dummy " record for the 1% exception, but it feels
"unclean ". But if it makes it easier, so be it.
Right now I am running 4.0, but I 'm not tied to any version yet.

Thanks
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=mysql @(protected)