how to concat two columns into one with the existing column name in mysql?

后端 未结 6 1552
旧时难觅i
旧时难觅i 2020-12-07 13:22

I want to concatenate two columns in a table with a existing column name using mysql.

An example: I am having a column FIRSTNAME and LASTNAME

6条回答
  •  無奈伤痛
    2020-12-07 13:35

    Instead of getting all the table columns using * in your sql statement, you use to specify the table columns you need.

    You can use the SQL statement something like:

    SELECT CONCAT(FIRSTNAME, ' ', LASTNAME) AS FIRSTNAME FROM customer;
    

    BTW, why couldn't you use FullName instead of FirstName? Like this:

    SELECT CONCAT(FIRSTNAME, ' ', LASTNAME) AS 'CUSTOMER NAME' FROM customer;
    

提交回复
热议问题