Re: simple sql problem
| From: | John W. Holmes | Date: | Fri, 25 Jul 2003 11:02:51 +0000 |
| Subject: | Re: simple sql problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-29471@lists.php.net to get a copy of this message | ||
Merlin wrote:
Hello , I have a sql problem which seems to be simple, but I am kind of stuck, There are 2 tables with IDs. I would like to find out which ID from table one is not in table 2. My statement: SELECT ap. * FROM pictures p , album_pictures ap WHERE ap.pic_id != p.pic_id returns of course all the ids from table pictures which are not in table album_pictures, but I would like to have it the other way arround.So you want all IDs in album_pictures that are not in pictures? SELECT ap.id FROM album_pictures ap LEFT JOIN pictures p ON ap.id = p.id WHERE p.id IS NULL The people that "need" sub-selects for things like this need to learn some more SQL... but we're getting off topic. :) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com