【发布时间】:2017-07-14 22:21:11
【问题描述】:
我是 psql 的新手。 我有一张“宠物”桌,如下所示。
name | species | owner | gender | color
-------------+---------+--------------------+--------+---------------
Nagini | snake | Lord Voldemort | female | green
Hedwig | owl | Harry Potter | female | snow white
Scabbers | rat | Ron Weasley | male | unspecified
Pigwidgeon | owl | Ron Weasley | male | grey
Crookshanks | cat | Herminone Granger | male | ginger
Mrs Norris | cat | Argus Filch | female | dust-coloured
Trevor | toad | Neville Longbottom | male | brown
如何连接字符串并以给出“Ron Weasley 有 X 个宠物”(其中 X = 2)的方式输出字符串?
我知道 X=2 部分的 'select count(name) from pets where owner = 'Ron Weasley';',但不确定如何在 PSQL 中连接和输出字符串。
【问题讨论】:
标签: string psql string-concatenation