Home > OS >  Adding a space seperating string
Adding a space seperating string

Time:01-14

How to add space between two name columns concatenated in SQL ?

SELECT CONCAT(a.first_name, a.last_name), f.title, f.description, f.length
FROM actor a
JOIN film_actor fa
ON a.actor_id = fa.actor_id
JOIN film f
ON f.film_id = fa.film_id

snapshot of result of query

i want to have space between names like "PenelopeGuiness" to "Penelope Guiness"

CodePudding user response:

SELECT CONCAT(a.first_name, " ", a.last_name), f.title, f.description, f.length
FROM actor a
JOIN film_actor fa
ON a.actor_id = fa.actor_id
JOIN film f
ON f.film_id = fa.film_id

CodePudding user response:

I tried to add ' ' inside CONCATE parameters but id did not work! Anyway, I just found below solution and it worked.

SELECT a.first_name || ' ' || a.last_name AS full_name
  • Related