开发者

How to combined first_name and last_name using sql query?

开发者 https://www.devze.com 2023-01-21 19:31 出处:网络
There are two columns in database as name FIRST_NAME and LAST_NAME.i want to join both the name and display in single column. The query which is used by me is give开发者_开发问答n below but it gives e

There are two columns in database as name FIRST_NAME and LAST_NAME.i want to join both the name and display in single column. The query which is used by me is give开发者_开发问答n below but it gives error as Incorrect syntax near 'NAME'.

Modify the query:

SELECT [CREATED_ON], MUD.PK_ID AS USER_ID, 
(MUD.FIRST_NAME + ' ' + MUD.LAST_NAME NAME) 
AS NAME FROM USER_TABLE


Remove the erroneous 'NAME'. e.g.

SELECT [CREATED_ON], MUD.PK_ID AS USER_ID, (MUD.FIRST_NAME + ' ' + MUD.LAST_NAME) 
AS NAME FROM USER_TABLE


SELECT 
   [CREATED_ON], 
   MUD.PK_ID AS USER_ID, 
   (MUD.FIRST_NAME + ' ' + MUD.LAST_NAME) AS [NAME]
FROM
   USER_TABLE

The parentheses around the expression MUD.FIRST_NAME + ' ' + MUD.LAST_NAME are optional.

0

精彩评论

暂无评论...
验证码 换一张
取 消