相关疑难解决方法(0)

在PostgreSQL中插入带单引号的文本

我有一张桌子test(id,name).

我需要插入样值: user's log,'my user',customer's.

 insert into test values (1,'user's log');
 insert into test values (2,''my users'');
 insert into test values (3,'customer's');
Run Code Online (Sandbox Code Playgroud)

如果我运行上述任何语句,我会收到错误.

如果有任何方法可以正确地做到这一点请分享.我不想要任何准备好的陈述.

是否可以使用sql转义机制?

postgresql quotes insert special-characters

377
推荐指数
5
解决办法
32万
查看次数

如何在Postgres SELECT中连接列?

我有两个字符串列ab一个表foo.

select a, b from foo返回值ab.但是,串联ab不起作用.我试过了 :

select a || b from foo
Run Code Online (Sandbox Code Playgroud)

select  a||', '||b from foo
Run Code Online (Sandbox Code Playgroud)

从评论更新:两列都是类型character(2).

sql postgresql types concatenation coalesce

133
推荐指数
5
解决办法
23万
查看次数

合并两列并添加到一个新列中

在PostgreSQL中,我想使用SQL语句组合两列并从中创建一个新列.

我正在考虑使用concat(...),但有更好的方法吗?
最好的方法是什么?

sql postgresql null concatenation

31
推荐指数
3
解决办法
9万
查看次数