Column References#
A column can be referenced in the form:
[correlation.]column_name
where correlation could be:
a table name (possibly qualified with a schema name)
an alias for a table
omitted if
column_nameis unique across all tables in the query.
mydb=> SELECT p.product_name, p.unit_price AS buying_price,
mydb-> public.products.price AS selling_price, items_in_stock, last_delivery_date
mydb-> FROM purchases p JOIN products ON p.product_name = products.name
mydb-> LIMIT 5;
product_name | buying_price | selling_price | items_in_stock | last_delivery_date
--------------+--------------+---------------+----------------+--------------------
Apples | 23.80 | 25.00 | 100 | 2023-07-24
Apples | 24.10 | 25.00 | 100 | 2023-07-25
Apples | 23.50 | 25.00 | 100 | 2023-07-28
Bananas | 8.50 | 10.00 | 32 | 2023-07-23
Bananas | 9.00 | 10.00 | 32 | 2023-07-25
(5 rows)