How to join two values from different columns of the same table in Sqlite3?

3398 views sql
-2

I have first_name and last_name column in the same table. I want to join and put them in a new column called full_name still in the same table. How can I do it? I've googled it but found only joining two or more columns from different tables.

answered question

1 Answer

8

You want to concatenate them, not join them. So, use the concatenation operator:

select (first_name || ' ' || last_name) as full_name
from t;

SQLite does not support generated columns. But if you want full_name to be available for more than one query, then you can define a view:

create view v_t as
    select t.*, (first_name || ' ' || last_name) as full_name
    from t;

posted this

Have an answer?

JD

Please login first before posting an answer.