Home Concat two json fields in one column in POSTGRESQL 9.6

# Concat two json fields in one column in POSTGRESQL 9.6

galiolio
1#
galiolio Published in 2017-12-07 14:03:32Z
 Hello here is my query : SELECT id,objecttype,(content->>'ip' || content->>'mask') as content, FROM public."Route"  I'd like to concat these two json fields (ip,mask) but with a space betwen them. I tried to use concat function, it works but I don't have the space between. This is the error generate from the query above : ERROR: operator does not exist: text ->> unknown LINE 1: SELECT id,objecttype,(content->>'ip' || content->>'ip') as c...  The query works well with only one field, but I need two have the concatenation between these fields with a space between them. Thanks
YCF_L
2#
 You can use cast : SELECT id, objecttype, (cast(content->>'ip' as text) || ' ' || cast(content->>'mask' as text)) as content FROM public."Route" 
 You need to login account before you can post.
Processed in 0.327086 second(s) , Gzip On .