如何在python中组合sqlite中的两列?

2024-09-27 00:21:02 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在sqlite3中组合两个列?我知道我可以在select语句中使用+,但是当我在python中尝试以下代码时:

select first+last as name from users 

它给了我0。在

我试过这种说法

^{pr2}$

我弄错了。在

我想在一列中显示名字和姓氏,如下所示:

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

Tags: 代码namefromas语句名字selectusers
2条回答

如果有空行,则可能需要尝试

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

as绑定比||更紧密,因此这需要parens:

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

在引号中使用"作为\"

^{pr2}$

相关问题 更多 >

    热门问题