Chapter 9 SQL Statements
497
This is an exception to the general rule that where a table is identified with a
correlation name and without a correlation name in the same statement, two
instances of the table are considered.
Consider the following example:
DELETE
FROM table_1
FROM table_1 AS alias_1, table_1 AS alias_2
WHERE ...
In this case, there are two instances of
table_1
in the second FROM clause.
The statement will fail with a syntax error as it is ambiguous which instance
of the
table_1
from the second FROM clause matches the first instance of
table_1
in the first FROM clause.
♦
SQL/92 Entry level compliant. The use of more than one table in the
FROM clause is a vendor extension.
♦
Sybase Supported by Adaptive Server Enterprise, including the
vendor extension.
♦ Remove employee 105 from the database.
DELETE
FROM employee
WHERE emp_id = 105
♦ Remove all data prior to 1993 from the fin_data table.
DELETE
FROM fin_data
WHERE year < 1993
♦ Remove all orders from sales_order_items table if their ship date is
older than 1994-01-01 and their region is Central.
DELETE
FROM sales_order_items
FROM sales_order
WHERE sales_order_items.id = sales.order.id and
ship_date < ’1994-01-01’ and region =’Central’
Standards and
compatibility
Examples