SQLite Forum

How can I split a name column into first and last names?
Login
When you (or somebody else) wrote <code>
  CREATE TABLE people (name TEXT, ...)
</code>instead of <code>
  CREATE TABLE people (firstname TEXT, restofname TEXT, ...)
</code>, the decision was made then to either never care about distinguishing components of a name or be forced to desperate measures to maybe extract them.

You can, if desperate enough, use the instr() and substr() functions, documented at [Built-In Scalar SQL Functions](https://sqlite.org/lang_corefunc.html), to extract the first space-delimited clump of characters from your "names" column. I leave the mechanics to you, (being not so desperate myself.)

Be warned that queries involving such expressions may be slow because they force a full table scan and evaluation of those string functions for each row.

You may want to investigate database normalization for future work.