Bit*_*Das 4 sql postgresql string-concatenation
我有一个宽度和高度(均为整数)的表。我想按原样显示它。例如:width = 300 and height =160。Area = 300 x160。我正在使用以下查询
select cast(concat(width,'x',height) as varchar(20)) from table;
Run Code Online (Sandbox Code Playgroud)
要么
select concat(width,'x',height) from table;
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误。
ERROR: function concat(character varying, "unknown", character varying) does not exist
Hint: No function matches the given name and argument types. You may need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)
谁能告诉我该怎么做?谢谢
按以下方式使用||:https : //www.postgresql.org/docs/current/static/functions-string.html
select width || 'x' || height from table;
Run Code Online (Sandbox Code Playgroud)
小提琴示例:http ://sqlfiddle.com/#!15/ f10eb/1/0