INTERSECT sound very much like UNION DISTINCT
(http://dev.mysql.com/doc/mysql/en/UNION.html) because this query should
give you what you asked for and is very similar to yours:
(SELECT ID_ENTRY FROM table WHERE ID_AGE = 1)
UNION DISTINCT
(SELECT ID_ENTRY FROM table WHERE ID_AGE=2)
However, I can also think of other ways of answering this same question
SELECT ID_ENTRY, count(1)
FROM table
WHERE id_age in (1,2)
GROUP BY id_entry
HAVING count(1)=2
SELECT t1.ID_ENTRY
FROM table t1
INNER JOIN table t2
ON t1.id_entry = t2.id_entry
AND t1.id_age=1
AND t2.id_age=2
Use whichever seems best for your circumstances
Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine
news <[EMAIL PROTECTED]> wrote on 08/12/2004 02:48:21 PM:
> I have the following table:
> +---------+-------------+
> | ID_AGE | ID_ENTRY |
> +---------+-------------+
> | 1 | 1 |
> | 1 | 4 |
> | 1 | 5 |
> | 2 | 1 |
> | 2 | 2 |
> | 2 | 3 |
> | 2 | 4 |
> | 2 | 6 |
> | 2 | 7 |
> | 2 | 8 |
> | 2 | 10 |
> | 2 | 11 |
> | 2 | 13 |
> | 2 | 14 |
> | 2 | 15 |
> | 2 | 19 |
> | 2 | 20 |
> | 2 | 21 |
> | 2 | 22 |
> | 2 | 24 |
> | 3 | 14 |
> | 3 | 16 |
> | 3 | 17 |
> | 3 | 18 |
> | 3 | 19 |
> | 3 | 22 |
> +---------+--------------+
>
> And since INTERSECT is not currently supported how do I select the
ID_ENTRY
> that has both 1 and 2 for ID_AGE
>
> SELECT ID_ENTRY WHERE ID_AGE = 1
> INTERSECT
> SELECT ID_ENTRY EHRE ID_AGE=2;
>
> The results should be 1 and 4.
>
> Thanks in advanced.
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
>