mysql string concatenation returns 0

前端 未结 4 2335
渐次进展
渐次进展 2021-02-19 15:23

im trying to concatenate 3 columns in a select query to show in one column in the results. the column is called DelPostalName and for some reason always shows a \'0\' when i run

相关标签:
4条回答
  • 2021-02-19 15:59

    You should use CONCAT (as a few people have mentioned) like this:

    CONCAT(isc_orders.ordShipFirstName,' ',
    isc_orders.ordshiplastname,' ',
    isc_orders.ordshipcompany)
    AS DelPostalName
    
    0 讨论(0)
  • 2021-02-19 16:03

    The result appears as zero since you are trying to arithmetically add the strings to each other.

    The correct method for concatenating strings in MySQL is using the CONCAT(str1, str2, str3) function.

    Here is the manual for the function.

    PS: if you want to concate with a seperator use CONCAT_WS() - also in the same manual

    0 讨论(0)
  • 2021-02-19 16:05

    Try using concat to concatenate columns/strings.

    0 讨论(0)
  • 2021-02-19 16:08

    I think you should use concat for concatenation, not + :)

    0 讨论(0)
提交回复
热议问题