I have a question about determining which case
occurred when there are no matches - using two tables.

Scenario:
- two tables, one for photos, and one for collections
- zero or more photos can belong to a collection
- the database may not know the collection_id requested
     (i.e. the user on the browser side did something to request
     a non-existent collection)

We can hit:
a) no collection
b) a collection that hasn't had any photos moved/uploaded to it yet, or..
c) a collection with one or more photos (the "normal, everything's fine" case)

Here's the php setting up the query...

// shortened version for posting question...
// there are many more fields...
$sql_str =<<<EOD
select
    photo.photo_id AS photo_id,
    collection.collection_dir AS collection_dir
from photo, collection
    where photo.collection_id = $collection
    and collection.collection_id = $collection
EOD;
    $sql_result = $db->query($sql_str);

When I check the number of rows returned, and get
0, I have no way (yet) of knowing why (no collection,
or just no photos in a collection).

Should I be using COUNT/GROUP BY?

thanks for any ideas!

-- 
Daniel L. Smith - [EMAIL PROTECTED] - Sonoma County, CA
AIM: JavaE36M3  ICQ: 12834734
http://resume.daniel.org






---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to