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

sql server split string last

SELECT SUBSTRING( string , LEN(string) -  CHARINDEX('/',REVERSE(string)) + 2  , LEN(string)  ) FROM SAMPLE;
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 :: sql like case sensitive 
Sql :: mysql show foreign keys column 
Sql :: set column width in sqlplus 
Sql :: soql update query 
Sql :: sql set data from a select query to a temp table and insert 
Sql :: import database mysql command line 
Sql :: mysql create table if not exists 
Sql :: sql table backup 
Sql :: unique element in sql 
Sql :: distinct in sql 
Sql :: divide by zero error in sql 
Sql :: postgres select except 
Sql :: min mysql 
Sql :: difference between in and between in sql 
Sql :: convert negative to positive in sql 
Sql :: sql order of operations 
Sql :: connect by query in oracle 
Sql :: Caused by: java.lang.RuntimeException: Unable to obtain credentials to communicate with the Cloud SQL API 
Sql :: union syntax in oracle 
Sql :: insert data into multiple tables mysql 
Sql :: mysql check all tables 
Sql :: execution order in sql 
Sql :: getting customers with no orders sql 
Sql :: oracle create index if not exists 
Sql :: How to create a comulative Sum column in mysql 
Sql :: update query in sql 
Sql :: identify rows with 2 same column value and delete duplicate mysql 
Sql :: select all columns except one sql 
Sql :: find in set in postgresql 
Sql :: sql: extract day text from datetime value 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =