Search Postgresql Archives

UNION or OR / INTERSECT or AND ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux