After my last post I felt like maybe I should revisit the idea. Espeically after at least one comment from a person claiming to never use ORs, which is understandable, but they refused to use UNIONs as well. Instead they opted to use UNION ALLs for everything.
The first thing I want to make clear is that ORs do have thier place. When you move into PL/SQL from standard (if you can call that) SQL ORs have a legimate place in your code much like they would any other programming language (again, if you can call PL/SQL a true programming language).
First lets clarify the differences here. A UNION will take the results of two queries, compare them, and only return to you the distinct rows. A UNION ALL will return duplicate rows if they exist within the results. So in the example I gave in my last post you wouldn’t want an UNION ALL, it would make your query return duplicates. So if you were creating a report involving invoices you’re totals could come out wrong because it might return certain invoices twice depending on how it’s connected to the rest of the data.
Enjoy the Penguins!