Skip to content

G-3130: Try to use ANSI SQL-92 join syntax.

Major

Maintainability, Portability

Reason

ANSI SQL-92 join syntax supports the full outer join. A further advantage of the ANSI SQL-92 join syntax is the separation of the join condition from the query filters.

Example (bad)

1
2
3
4
5
6
7
8
select e.employee_id
      ,e.last_name
      ,e.first_name
      ,d.department_name
  from employees e
      ,departments d
 where e.department_id = d.department_id
   and extract(month from e.hire_date) = extract(month from sysdate);

Example (good)

1
2
3
4
5
6
7
8
select emp.employee_id
      ,emp.last_name
      ,emp.first_name
      ,dept.department_name
  from employees emp
  join departments dept
    on dept.department_id = emp.department_id
 where extract(month from emp.hire_date) = extract(month from sysdate);