Jeff Levine
Jeff Levine

Reputation: 2163

Why CAN I use aliases in the WHERE clause? (Oracle XE 11g)

While studying for the 1Z0-051 exam, I've read in many places that column aliases cannot be used in the WHERE clause. However, when I submit the following query:

SELECT e.first_name, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id
AND e.first_name LIKE 'B%';

I get the following results:

FIRST_NAME              DEPARTMENT_NAME
---------------------   -----------------------
Bruce                   IT
Britney                 Shipping

Can someone explain why these aliases are working? Even better, what's the overall rule/concept I'm missing?

Upvotes: 1

Views: 820

Answers (1)

juergen d
juergen d

Reputation: 204766

You can not use column name aliases in a where clause, but table name aliases which you do.

Upvotes: 3

Related Questions