What .* does in PostgreSQL ? and is there no necesarry to write AS to rename a variable?

I saw this query, and I'm still not really a pro in PostgreSQL. I want to know what does the .* after the vi and also i see that they rename tables without the as, it works but I wanted to know if its a common practice.

 select vi.* , coalesce(ordenes, 0)
 from vistas_por_jose vi
 left join ventas ve
 on vi.store_id = ve.store_id

Upvotes: -1

Views: 39

Answers (1)

Simeon Pilgrim
Simeon Pilgrim

Reputation: 25938

This select all columns from the vi alias, which is the table vistas_por_jose . Thus none of the ve alias (ventas ) will be selected. Unless ordenes is from ventas, at which point it really should be using the alias.

Upvotes: 1

Related Questions