我想在SQL中将'given'和'surname'列放在'fullname'中,我将如何进行这样做。 TNX

时间:2022-01-03 03:39:04

I currently have them separated but would prefer to have both together in one column.

我目前将它们分开,但更愿意将它们放在一列中。

2 个解决方案

#1


0  

SELECT CONCAT(given, ' ', surname) AS fullname FROM tablename

or for null safe,

或者对于零安全,

SELECT CONCAT_WS(' ', given, surname)  AS fullname FROM tablename

#2


0  

you can concatenate them using:

你可以使用以下方法连接它们:

select CONCAT(given,' ',surname) as fullname;

#1


0  

SELECT CONCAT(given, ' ', surname) AS fullname FROM tablename

or for null safe,

或者对于零安全,

SELECT CONCAT_WS(' ', given, surname)  AS fullname FROM tablename

#2


0  

you can concatenate them using:

你可以使用以下方法连接它们:

select CONCAT(given,' ',surname) as fullname;