views:

39

answers:

2

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 given 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
+3  A: 

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
William
A: 
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.

Mitch Wheat