Thursday, August 30, 2018

Camel Case in SQL

Below is a query to help make the Camel Case in the LAST_NAME. The first name has already been Camel Cased so I left it alone. SELECT concat(first_name,' ', concat(UPPER(LEFT(LAST_NAME,1)),'',LOWER(SUBSTRING(LAST_NAME,2,60)))) name FROM table;

Below is just a query of all the fields I needed then export the resultset into a file name email3.txt SELECT concat(first_name,' ', concat(UPPER(LEFT(LAST_NAME,1)),'',LOWER(SUBSTRING(LAST_NAME,2,60)))) name, email, 'Saigon South International School' school, job_title FROM cardinfo_cardinfo where email <> '' and is_leaving_teacher = 0 and job_title <> '' into outfile '/tmp/email3.txt';