>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
Well, that's half the solution. That gives you the difference of
user1 and user2, but you also need the difference of user2 and user1.
You could run both difference queries and INSERT INTO a temp table.
After both insert queries, you'd have your Except result.
Bob Hall
Know thyself? Absurd direction!
Bubbles bear no introspection. -Khushhal Khan Khatak
MySQL list magic words: sql query database
---------------------------------------------------------------------
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