Difference between revisions of "Non-Equality Joins"

From rbachwiki
Jump to navigation Jump to search
(Created page with "'''With an equality join, the data value of a record stored in the common column for the first''' '''table must match the data value in the second table. However, in many case...")
 
 
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:
'''an equal sign—meaning there are no equivalent rows in the tables to be joined.'''
'''an equal sign—meaning there are no equivalent rows in the tables to be joined.'''


'''A non-equality join enables you to store a range’s minimum value in one column of a'''
'''record and the maximum value in another column. So instead of finding a column-to column'''
'''match, you can use a non-equality join to determine whether the item being shipped'''
'''falls between minimum and maximum ranges in the columns.'''
== Traditional Non-Equality JOIN ===
SELECT b.title, p.gift
FROM books b, promotion p
WHERE b.retail BETWEEN p.minretail AND p.maxretail;


=== Non-Equality Joins: JOIN Method ===
SELECT b.title, p.gift
FROM books b JOIN promotion p
  ON b.retail BETWEEN p.minretail AND p.maxretail


[[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]]
[[#Select Command|Back To Top]]-[[Main_Page| Home]] - [[Oracle_SQL|Category]]

Latest revision as of 23:23, 23 October 2017

With an equality join, the data value of a record stored in the common column for the first table must match the data value in the second table. However, in many cases, there’s no exact match. A non-equality join is used when the related columns can’t be joined with an equal sign—meaning there are no equivalent rows in the tables to be joined.

A non-equality join enables you to store a range’s minimum value in one column of a record and the maximum value in another column. So instead of finding a column-to column match, you can use a non-equality join to determine whether the item being shipped falls between minimum and maximum ranges in the columns.

Traditional Non-Equality JOIN =

SELECT b.title, p.gift
FROM books b, promotion p
WHERE b.retail BETWEEN p.minretail AND p.maxretail;

Non-Equality Joins: JOIN Method

SELECT b.title, p.gift
FROM books b JOIN promotion p
  ON b.retail BETWEEN p.minretail AND p.maxretail

Back To Top- Home - Category