Using the Cartesian Product

Valid joins are essential to producing comprehensible multitable query results, unless one of the tables contains a single row—perhaps a system variable or a stored value. In that case, you can use a Cartesian product between two tables without fear. For example, test3 contains the current tax rate.

SQL
create table test3
(rate decimal not null,
date_start date not null default current date)
[table created]
insert test3 (rate)
values (.08)
[1 row]

You can use test3 with titles without a join to calculate the base-plus-tax price of books.

SQL
select title_id as Book, price as BasePrice, price + ( price * rate)
as TaxPrice
from titles, test3 where type = 'business' order by title_id Book BasePrice TaxPrice ====== ========== ...

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.