Re: simple sql problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Any database that supports nested queries (unfortunatly this excludes MySQL) ... you can do

   select pic_id from pictures where pic_id not in (select pic_id from
   album_pictures)


Otherwise you might have a harder time with MySQL ... something like set difference if it supports it (I'm not sure what it supports to facilitate your need)
HTH


~Steve

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.

Can anybody help on this.

Thanx a lot in advance for any help,

Merlin







[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux