On 06-Jul-01 Artem Koutchine wrote:
> Hi!
> There are two tables:
<random snipage>
> TASK:
> select all ids for names which are unique among both tables:
<snip>
> RETURNS: 3,4,5,6
>
> The trick is to do it in ONE SQL statement.
>
Why one ? is this a test ?
mysql> create table t (id int not null, name char(10), key(id))
> TYPE=MERGE UNION=(a,b);
Query OK, 0 rows affected (0.00 sec)
mysql> select id, count(*) as cnt from t group by id having cnt=1;
+----+-----+
| id | cnt |
+----+-----+
| 3 | 1 |
| 4 | 1 |
| 5 | 1 |
| 6 | 1 |
+----+-----+
4 rows in set (0.00 sec)
Regards,
--
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.
---------------------------------------------------------------------
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