SELECT sh.id AS sh_identifier
my column name is id
, what is the sh.
bit before it called and how do i use this correctly? than开发者_如何学JAVAks.
Its a table or view name or table alias or in some cases an inline view alias
Table Name
SELECT sh.id as sh_identifier
FROM sh
Table alias
SELECT sh.id as sh_identifier
FROM mytable sh
Inline view
SELECT sh.id as sh_identifier
FROM (SELECT * FROM mytable) sh
You usually use it to define the table names in more advanced queries.
SELECT mytable.id AS sh_identifier FROM mytable
sh.
is the name of the table, or an alias (SELECT * FROM a_long_table_name AS sh
) of one.
sh
is the table name
sh.id
is the column id from the table sh
See the documentation for more information
sh
specifies the name of the table where the corresponding field exists.
In statements where just one table is used it is not necessary, but it is required to avoid ambiguity when more than one table is used and any two tables have a field with the same name.
It's aliasing the sh.id field as sh_identifier. In this case, the person who wrote the query just tried to give a more meaningful name to the id column of the sh table.
As this is only part of the full query, the bit that answers your question is missing.
the sh.
will refer to a Table - or an alias of one - which appears in the FROM
clause.
If you're only selecting from one table, it's not mandatory.
精彩评论