Falko
Falko

Reputation: 1035

How does this dot notation within SQL work?

I'm working with some SQL and trying to understand what is going on.

Within the select there are what seem like variables s.id s.status

with 
    last_transactions as (
        select 
            s.id as station_id, 
            s.status as status,
            case...........

What are these s. items and how do they work?

Upvotes: 1

Views: 759

Answers (4)

Meetts
Meetts

Reputation: 13

S is table alias and through .dot we can access that table column.

Example..

Select S.id from Sample as S

It give you all id's of the sample table.

Upvotes: 1

MarizaV.
MarizaV.

Reputation: 11

s. is a reference to the table name that derives from the From clause that probably follows in your query. The part after the . is the column name.

For example s.id means: Column 'id' from table 's'

Upvotes: 1

GDes00
GDes00

Reputation: 285

the s is the table name. s.id means the id column of the s table.

Upvotes: 1

Himanshu
Himanshu

Reputation: 3970

. notation is used to reference columns mainly of a table, view etc. schema objects or an aliased name of a schema object as above you have used s as alias name of some table so using s. the part after dot references to the column in that s or table aliased

Upvotes: 1

Related Questions