"AS" equivalent in sqlite

I start with sqlite from mysql. maybe my question is dumb, but I can not find the equivalent of "AS" in mysql, for example.

Example: "SELECT firstName || ' ' || lastName AS fullName FROM myTable;"

Is it possible?

Thanks in advance!

+4
source share
3 answers

SQLite also supports the use of AS , as shown in this diagram from the Syntax Diagrams page for SQLite :

column result :

Syntax Diagrams For SQLite

Why do I want to use "AS"?

Because it allows you to give a descriptive name for each column in your result set. You can use this name to refer to a column when reading results.

+10
source

The AS keyword will work the same as in SQLite, as in mysql. See, for example, a link to SQLite syntax (in particular, the production results column ). Second question: SQLite supports || concatenation operator .

Note that you want to use an alias for SELECT ed values ​​anyway if you intend to reference result columns by name, as the sqlite3_column_name documentation:

The result column name is the value of the "AS" clause for this column if an AS clause exists. If there is no AS clause, the column name is not specified and can change from one version of SQLite to the next.

+3
source

SELECT firstName || ' ' || lastName fullName FROM myTable; works for me

UPDATE: sqllite did not like the user, so he did not know that the AS keyword exists in it. I would not use keyworkd AS in any statement (as suggested by my answer), since it helps very well in reading the code.

+1
source

Source: https://habr.com/ru/post/1398628/


All Articles