MySQL, Concatenate two columns

后端 未结 4 1391
醉酒成梦
醉酒成梦 2020-11-28 08:44

There are two columns in a MySQL table: SUBJECT and YEAR.

I want to generate an alphanumeric unique number which holds the concatenated da

4条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 08:53

    You can use php built in CONCAT() for this.

    SELECT CONCAT(`name`, ' ', `email`) as password_email FROM `table`;
    

    change filed name as your requirement

    then the result is

    and if you want to concat same filed using other field which same then

    SELECT filed1 as category,filed2 as item, GROUP_CONCAT(CAST(filed2 as CHAR)) as item_name FROM `table` group by filed1 
    

    then this is output

提交回复
热议问题