SQLite problem selecting two columns as one

2019-03-10 19:02发布

Basic table with empname and empdpt.
In a Sql Server table, I can do Select empname + ' ' + empdpt as expr1 no problem.
Can't do the same using Sqlite!!
When I try to combine two columns [with data], I get back a 0.
I've tried in sqliteman and sqliteadmin as well as Server Explorer in VS.

标签: sqlite3
3条回答
【Aperson】
2楼-- · 2019-03-10 19:42

Try using the following:

SELECT ("test" || " " || "test2") AS expr1 ;

Update

If these are columns you can do something similar: SELECT (column1 || " " || column2) AS expr1 FROM your_table;

查看更多
仙女界的扛把子
3楼-- · 2019-03-10 19:50
Select empname || " " || empdpt as expr1 

The sqllite concat is the same as PostGreSQL ( || ) and not MYSQL or MSSQL 'CONCAT'

查看更多
来,给爷笑一个
4楼-- · 2019-03-10 19:55

for those who are trying to use the (working) solution of @merkuru

SELECT (column1 || " " || column2) AS expr1 FROM your_table;

in eclipse or another editor:

you have to cancel the " with \

something like:

SELECT (column1 || \" \" || column2) AS expr1 FROM your_table;

that's works perfect

查看更多
登录 后发表回答