Skip to content

Instantly share code, notes, and snippets.

@sirusdas
Last active April 27, 2019 05:53
Show Gist options
  • Save sirusdas/ae8d7871a2863e8535bcfe1474e4d6c1 to your computer and use it in GitHub Desktop.
Save sirusdas/ae8d7871a2863e8535bcfe1474e4d6c1 to your computer and use it in GitHub Desktop.
Useful SQL queries

Query for LIKE IN together

SELECT *
FROM `pincodeMaster`
WHERE stateName REGEXP '^ANDAMAN|ASSAM|BIHAR|Chattisgarh|DADRA|DAMAN|DELHI|GOA|HIMACHAL PRADESH|JAMMU|JHARKHAND|MADHYA PRADESH|MEGHALAYA|MIZORAM|NAGALAND|PONDICHERRY|RAJASTHAN|SIKKIM|TRIPURA|WEST BENGAL|TAMILNADU|Andhra Pradesh|Kerala|Karnataka|Maharashtra|Gujarat|Haryana|Punjab|Uttar Pradesh|Uttarakhand|Orrisa|Andrapradesh|Telangana (.*)'
GROUP BY stateName 

Will search for all the states that matches similar to like and case-insensitive too.

First letter Capital and rest all small

UPDATE tb_Company
SET CompanyIndustry = CONCAT(UCASE(LEFT(CompanyIndustry, 1)), 
                             LCASE(SUBSTRING(CompanyIndustry, 2)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment