UNION or OR / INTERSECT or AND ? - Mailing list pgsql-general

From David W
Subject UNION or OR / INTERSECT or AND ?
Date
Msg-id 1139321046.697952.264710@g44g2000cwa.googlegroups.com
Whole thread Raw
Responses Re: UNION or OR / INTERSECT or AND ?  (Michael Glaesemann <grzm@myrealbox.com>)
List pgsql-general
Hello,

do i have to prefered to use UNION and INTERSECT or is it better with
OR and AND ?

Query example :

1. OR

SELECT a.designation, m.label FROM article a JOIN manufacturer m ON
m.id = a.manufacturer_id
WHERE a.designation || m.label ILIKE '%elec%'
OR a.designation || m.label ILIKE '%compa%'
OR a.designation || m.label ILIKE '%xs%'

2. UNION

SELECT a.designation, m.label FROM article a JOIN manufacturer m ON
m.id = a.manufacturer_id WHERE a.designation || m.label ILIKE '%elec%'
UNION
SELECT a.designation, m.label FROM article a JOIN manufacturer m ON
m.id = a.manufacturer_id WHERE a.designation || m.label ILIKE '%compa%'
UNION
SELECT a.designation, m.label FROM article a JOIN manufacturer m ON
m.id = a.manufacturer_id WHERE a.designation || m.label ILIKE '%xs%'

My actual database, is too small to see a real difference. That's why i
prefered to ask this newsgroup.

Thanks for your support,
David "Willou".
http://www.willou.net.


pgsql-general by date:

Previous
From: Ludwig Isaac Lim
Date:
Subject: Clarification Regarding Vacuum and template1
Next
From: Nikolay Samokhvalov
Date:
Subject: Re: Sequences/defaults and pg_dump