On 10 Oct 2002, at 21:28, Jan Peuker wrote:

> normally two tables are joined by two singular keys, for instance "id"
> which is (1) in both tables. But how do I join them over a id-field
> like this:(1,2,4)? I know, there is the WHERE id IN(...) function, but
> if I do a:
> SELECT dogs.name FROM dogs,pets WHERE dogs.id IN (pets.id) AND
> pets.name="dogs"
> I get, as expected, just one row. Is there another way?

It's not clear from your question what exactly you want.  First you 
talk about (1,2,4), but your sample query doesn't use those numbers 
at all and instead brings in a different column.  You don't give any 
clue about how dogs.name relates to pets.name.  Are they the same?

Maybe you want something like this:

   SELECT * FROM dogs INNER JOIN pets USING (id)
   WHERE pets.name = 'dogs';

Or maybe it's something like this:

   SELECT * FROM dogs INNER JOIN pets USING (id, name)
   WHERE pets.name = 'dogs';

Or maybe this:

   SELECT * FROM dogs INNER JOIN pets USING (id)
   WHERE pets.id IN (1, 2, 4);

If you want a better answer, we need a better explanation of what you 
have and what you want.

-- 
Keith C. Ivey <[EMAIL PROTECTED]>
Tobacco Documents Online
http://tobaccodocuments.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