Can you create a 'fact' table containing the infomration that you are
querying? This goes
against normalization but if the table will only be used for querying
purposes then this
will eliminate your need to perform joins. 

-----Original Message-----
From: Tim McDonough
To: [EMAIL PROTECTED]
Sent: 4/9/04 8:20 AM
Subject: Better Solution than Multiple Queries?

I have an application where I want to look for records that match 
certain criteria and then for each item found do a second lookup for 
additional information. Normally I would do a join. In this case 
however I want to display each of the results from the first of the 
two criteria whether or not the second part is found or not.

The solution I presently have does a query for the first criteria. 
Then, I loop through the results of that query and do another query 
for each returned row. This produces the desired results but requires 
a lot of queries, i.e.-- if the first query returns 1000 customers 
then I make 1000 additional queries to get the remaining info if it 
exists.


result1 = first query
for each row in result1
{
  result2 = second query
  display result1
        if result2 isn't empty then
        {
                display result2
        }
}

Is there a more efficient way to query the database and always display 
the information I presently get from the first query even if there are 
no matches found on the second?

Thanks for any suggestions.

Tim


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to