Apply GROUP_CONCAT and CONCAT on a integer type value


Hi,

As we know GROUP_CONCAT returns a string result with the concatenated non-NULL values from a group and CONCAT Returns the string that results from concatenating the arguments.

If we apply these function on any not char type field then it will be return result something like [BLOG-3B] and something like this. So to apply on non chars field like int type we can use CONVERT mysql function for it.

For example

SELECT concat(CONVERT(column1,char(8))," , ") AS id,group_concat(CONVERT(column2, CHAR(20)) separator '|') AS result FROM `tablename` WHERE 1 group by column1

Here CONVERT will convert value of field column1 into a char type. and CONVERT function will be work on it.

thanks.

Advertisements

One response to “Apply GROUP_CONCAT and CONCAT on a integer type value

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s