> SELECT images.filename, images.path, images.desc, categories.name FROM > images, relate, categories WHERE public = 1 AND relate.fromid = > images.id AND relate.toid = categories.id > > But what I need help with is getting all the images that has no > categorie associated with them in the table relate...
Give this a try: Select images.filename,images.path, images.desc >From images Left Join relate On (relate.fromid=images.id) Where public And relate.toid = 0 -- The LEFT JOIN will return all rows (w/ public <> 0) in the `images` table. It will try to match each row in the `images` table to a row or several rows in the `relate` table. Any rows that it cannot find a match for will be filled in with 0s or NULL values. These are the ones that you are interested in. If you wanted to find all of the ones with a relationship, you could just drop off the " = 0" part, or do a STRAIGHT JOIN (better). You could use any field from the relate table, actually, since they'll all be 0s or NULL, but I just picked `toid` at random. I don't do queries too often like this, so it's possible I might have omitted something by accident, but I think this should work for you. Feel free to get in touch with me directly and I'll see what I can do for ya. Sincerely, Andrew Moyer PHP Coder & Linux/MySQL Admin Jetson Direct Mail Services, Inc. --------------------------------------------------------------------- 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