(sorry for my poor english)
If you try this select operation over a sqlite database:
SELECT column AS 'alias 1' FROM table;
You get the expected column name:
alias 1
--------
result 1
result 2
but if your alias contains a dot "." ... you get a wrong column name:
SELECT column AS 'alias.1' FROM table;
1
--------
result 1
result 2
(all behind the dot is ommited in the column name)
Wow... It's weird...
anyone can help me?
thank you very much
UPDATE:
maybe it's just a bug in SQLiteStudio (the software where I'm testing my queries) and in QT (they both doesn't expect dots in alias names but sqlite does)
Use backticks around the column name User. FirstName. LastName which contains (.).
Blanks spaces are restricted in the naming convention of the database object's name and column name of the table.
You can rename a table or a column temporarily by giving another name, which is known as ALIAS. The use of table aliases means to rename a table in a particular SQLite statement.
To select a column name with spaces, use the back tick symbol with column name. The symbol is ( ` `).
Enclose your alias in double quotes.
SELECT 'test' AS "testing.this"
Output:
| testing.this |
test
Updated:
Double quotes are used to enclose identifiers in SQL, not single quotes. Single quotes are only for strings. In this case you are trying to ensure that "testing.this" is used as is and not confused as testing.this (testing
table this
column).
http://www.sqlite.org/faq.html#q24
Use backticks
SELECT column AS `alias.1` FROM table;
Or double quotes (ANSI standard) per the other answer
SELECT column AS "alias.1" FROM table;
Both verified in SQLite Manager for FireFox
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With