Reputation: 37
I'm editing some views and came across something that is new to me:
SELECT rn3.create_date
FROM receipt_note rn3
WHERE rn3.receipt_num = receipt_data.receipt_num
I'm just wondering what the rn3
does in the from part of the statement?
As there isn't a comma between them showing its another table and I dont see a table or view in my database called rn3.
Upvotes: 1
Views: 132
Reputation: 204924
It is called an Alias.
You can define another name to use in your queries. Mostly used as shorter name of tables to simplify your queries. Example:
select t.some_column
from very_long_table_name t
Or if you join the same table twice then you need aliases to distinguish between the two. Example:
select child.name, parent.name
from users child
join users parent on child.parent_id = parent.id
And as stated in comments: When using DB engines other than Oracle, you can but don't need to define the as
keyword:
select t.*
from some_table_name as t
Upvotes: 4