Nuh Yamin
Nuh Yamin

Reputation: 353

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

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.

Upvotes: 0

Views: 220

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1271003

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;

Upvotes: 1

Related Questions