A sort of Subset Union

Posted by admin on January 28th, 2009
1
2
3
4
5
6
7
8
9
SELECT A.UserId
FROM
(
      SELECT UserId FROM Users WHERE Email LIKE '%.com'
) A,
(
      SELECT UserId FROM Users WHERE Email LIKE '%er%'
) B
WHERE A.UserId = B.UserId

Result A:

10059
10060
10061
10062
10063
10082
10058
10088
10089

Result B:

10059
10063
10087
10089

Result query:

10059
10063
10089

If there are other ways to acomplish this, please let me know.

Lieven Cardoen aka Johlero

UNION & Order By

Posted by admin on January 27th, 2009

select supplier_id, supplier_name
from suppliers
where supplier_id > 2000
UNION
select company_id, company_name
from companies
where company_id > 1000
ORDER BY 2;

pixel UNION & Order By

Copyright © 2007 Lieven Cardoen. All rights reserved.