Skip to content

Instantly share code, notes, and snippets.

@shredder47
Last active January 13, 2021 07:07
Show Gist options
  • Save shredder47/c2880026cd02300f01fd98e0f57f866c to your computer and use it in GitHub Desktop.
Save shredder47/c2880026cd02300f01fd98e0f57f866c to your computer and use it in GitHub Desktop.
---------------
SUBSTRING_INDEX
---------------
SUBSTRING_INDEX(column_name,' ' , 1) // Not 0 Indexed!
--------
to_date
--------
to_date(col_with_date_as_string,'MM/yyyy') //parse date string to date type using the specified format - Returns it as yyyy-MM-dd
------------
IN statement
------------
SELECT 2 IN (1,2,3,4) -> 1
SELECT 5 IN (1,2,3,4) -> 0
usage--
SELECT IF((SELECT 2 IN (1,2,3,4)),'Found','Not Found') -> Found
SELECT IF((SELECT 55 IN (1,2,3,4)),'Found','Not Found') -> Not Found
------------------------
GREATEST statement
------------------------
GREATEST(3, 12, 34, 8, 25) -> 34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment