我在postgres中有一个表,其中有这三列id_0,turnr和标签。标签列的数据类型为hstore。当前我正在使用此查询,该查询不起作用
INSERT INTO relation_15_02_2020 (tags)
VALUES
(
'
"type"=>"restriction",
"restriction"=>"(select distinct(turnr) from relation_15_02_2020 ) "
'
);
我如何添加
"type"=>"restriction",
"restriction"=>" turnr value for respective id
id_0 = 1标签的期望输出
{"type"=>"restriction","restriction"=>"NoRightTurn"}
您要更新行,而不要插入新行:
update relation_15_02_2020
set tags = hstore(array['type', 'restriction'], array['restriction', turnr])
where id_0 = 1;
或者]
update relation_15_02_2020
set tags = hstore('type', 'restriction')||hstore('restriction', turnr)
where id_0 = 1;