开发者

how to combine two columns in sqlite in python?

How can I combine two columns in sqlite3? I know I can use + in a select statement, but when I've t开发者_开发知识库ried this code in python :

select first+last as name from users 

it gave me 0.

I have tried this statement

select first||" "||last as name from users

I'm getting error.

I want to show firstname and last name in one column, something like this:

'tara.panagop@where.com', 'tara panagop', 


as binds tighter than || so this needs parens:

select (first||" "||last) as name from users

ecape " in quotes as \":

cur.execute("select (first||\" \"||last) as name from users")


If you have null rows you might want to try

select (coalesce(first,'')||" "||coalesce(last,'')) as name from users
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜