How To Join Strings In SQL For Hive

Use the CONCAT function. It can be a bit confusing because joining strings, or concatenating (hence the abbreviation CONCAT), is usually done with a symbol like ‘&’ or ‘+’ in other systems and languages.

The syntax is pretty straight forward.


CONCAT(string1, string2, ...)

Let’s say you you had three string fields, address, city, and state from table contact_info
that you wanted to join (concatenate) together with commas and spaces inbetween. You would use the following code:


SELECT CONCAT(address,', ',city,', ',state)
FROM
contact_info

facebooktwittergoogle_plusredditpinterestlinkedinmail

Related books picked – and if possible read – by me. Sponsored by Amazon Associates.