The USING
clause is something we don't need to mention in the JOIN
condition when we are retrieving data from multiple tables. When we use a USING
clause, that particular column name should be present in both tables, and the SELECT
query will automatically join those tables using the given column name in the USING
clause.
For example, if there are two common column names in the table, then mention the desired common column name in the USING
clause.
USING
is also used while executing Dynamic SQL, like so:
EXECUTE IMMEDIATE 'DELETE FROM dept WHERE deptno = :num'
USING dept_id;
The USING clause
The USING
clause is used if several columns share the same name but you don’t want to join using all of these common columns. The columns listed in the USING clause can’t have any qualifiers in the statement, including the WHERE clause.
The ON clause
The ON
clause is used to join tables where the column names don’t match in both tables. The join conditions are removed from the filter conditions in the WHERE clause.