Joins Not Based on Equality

Joins not based on equality can be described by their comparison condition, as “less-than join,” “greater-than join,” and so forth. This example of a less-than join displays orders that were shipped on a date later than the sale (the company attempts to ship all orders on the day received):

SQL
select distinct s.sonum, s.stor_id, s.sdate,
 sd.date_shipped
from sales s, salesdetails sd
where s.sdate < sd.date_shipped and s.sonum = sd.sonum sonum stor_id sdate date_shipped =========== ======= ==================== ==================== 1 7066 Sep 13 1998 12:00 am Sep 15 1998 12:00 am 2 7067 Sep 14 1998 12:00 am Sep 15 1998 12:00 am 3 7131 Sep 14 1998 12:00 am Sep 18 1998 12:00 am 4 7131 Sep 14 1998 12:00 am Sep 18 1998 ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.