[nycphp-talk] simple mysql query help
Jim Hendricks
jim at bizcomputinginc.com
Tue Aug 6 11:24:28 EDT 2002
SELECT * FROM aaa WHERE aaa.ID NOT IN( SELECT ID FROM bbb )
DELETE FROM aaa WHERE aaa.ID NOT IT( SELECT ID FROM bbb )
aaa.ID and ID are the key fields which link aaa to bbb.
HTH,
Jim
----- Original Message -----
From: "cesar" <can at andrew.cmu.edu>
To: "NYPHP Talk" <talk at nyphp.org>
Sent: Tuesday, August 06, 2002 11:16 AM
Subject: [nycphp-talk] simple mysql query help
>
> i have two tables aaa and bbb
> aaa has {1 , 2}
> bbb has {1 , 3 }
>
> i want select those values in aaa that don't appear in bbb, and also
> another query that will delete those values in aaa which don't appear in
> bbb. if someone can please help me, i'm just a little stuck. i know i
> figured it out before, but right now i have no clue.
>
> A)
> mysql> select * from aaa;
> +------+
> | a |
> +------+
> | 1 |
> | 2 |
> +------+
>
> mysql> select * from bbb;
> +------+
> | a |
> +------+
> | 1 |
> | 3 |
> +------+
>
> B)i understand why this does what it does, but how do i correct it?
> mysql> select aaa.*, bbb.* from aaa, bbb where aaa.a != bbb.a;
> +------+------+
> | a | a |
> +------+------+
> | 2 | 1 |
> | 1 | 3 |
> | 2 | 3 |
> +------+------+
>
> thnka you in advance.
>
>
>
>
>
More information about the talk
mailing list