Search
 
SCRIPT & CODE EXAMPLE
 

SQL

split first name and last name in sql

# Name of table = names_table
# Name of column containing names = full_name
# Simply change the table and column name to what corresponds with your dataset

SELECT LEFT(full_name, STRPOS(primary_poc, ' ') -1 ) AS first_name,  
  		RIGHT(full_name, LENGTH(primary_poc) - STRPOS(primary_poc, ' ')) AS last_name, name
FROM names_table;

# NB: This does not capture middle names
Comment

Split string and get first and last element in sql server

DECLARE @String nvarchar(200) = 'I_love_my_country'

SELECT left(@String, charindex('_', @String) - 1) AS first_element 
SELECT reverse(left(reverse(@String), charindex('_', (reverse(@String))+'_' ) -1)) AS last_element 
Comment

PREVIOUS NEXT
Code Example
Sql :: oracle current timestamp insert statement 
Sql :: change table to innodb mysql 
Sql :: sql get guid 
Sql :: mysql modify default value 
Sql :: how to get the ddl for datafile in oracle tablespace 
Sql :: mysql copy table1 to table2 
Sql :: oracle limit user tablespace 
Sql :: helptext in sql 
Sql :: sql update from select 
Sql :: apex add months to date 
Sql :: sql select except null 
Sql :: how to delete table sqlite 
Sql :: row number mysql 
Sql :: Oracle Column Names of a table 
Sql :: get table column names sql laravel 
Sql :: varchar plsql 
Sql :: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client 
Sql :: postgresql array last element 
Sql :: ms sql truncate table vs delete 
Sql :: mysql public key retrieval is not allowed 
Sql :: install mysql 8 linux 
Sql :: mysql backup skip table 
Sql :: add unique constraint sql server multiple columns 
Sql :: date in where on datetime column clause mysql 
Sql :: docker mysql random root password 
Sql :: oracle undo usage by session 
Sql :: how to check xampp mysql password 
Sql :: datepart postgres 
Sql :: Suse Linux restart MySQL 
Sql :: disable trigger sql oracle 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =