On Tue, May 15, 2001 at 04:45:22PM +0200, Viktor van den Berg wrote:
> 
> Hi,
> 
> I am new to this list, so maybe this question is asked before.
> 
> I like to know how to use the except statement in MYSQL. EXCEPT is 
> (almost?) the same as an exlusive or (XOR):
> 
> select userid from user1
> except
> select userid from user2
> 
> The result is a data set containing userid's that are only availlable in 
> user1 or in user2. If the userid is availlable in user1 AND user2, then it 
> won't be availlable in the result.
> 
> The question is what syntax to use in MYSQL to achieve this result!

One of the possible ways would be

SELECT u1.userid
FROM user1 u1
LEFT JOIN user2 u2 ON u2.userid=u1.userid
WHERE u2.userid IS NULL;

G'luck,
Peter

-- 
This inert sentence is my body, but my soul is alive, dancing in the sparks of your 
brain.

---------------------------------------------------------------------
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