Home > Mobile >  How can I merge this query so that it returns only one column?
How can I merge this query so that it returns only one column?

Time:06-17

I have the following table:

Player Name         Nationality
--------------------------------
Romelu Lukaku       Belgian
Christian Pulisic   American
Kai Havertz         German
Masoun Mount        British
Reece James         British
Edouard Mendy       French
N'Golo Kante        French
Hakim Ziyech        Morrocan
Timo Werner         German
Thiago Silva        Brazilian
Ross Barkley        British

I tried the following query:

SELECT 
    REPLACE([Player Name], 'Reece', 'John'),
    REPLACE([Player Name], 'Christian', 'Chris') 
FROM 
    Players

This query returns two columns rather than just one. How can I make the query one so that only one column gets returned?

CodePudding user response:

You can use UNION tojoin rows vertically

SELECT REPLACE([Player Name], 'Reece', 'John') as name FROM Players
UNION
SELECT REPLACE([Player Name], 'Christian', 'Chris') FROM Players
  •  Tags:  
  • sql
  • Related