Contents
Dates and time
- FROM_UNIXTIME
1 | Unix timestamp to datetime: |
- UNIX_TIMESTAMP
1 | Datetime string to Unix timestamp: |
- date_format
1 | Rows for today: |
- Records in the last N days
1 | select * from table_name |
Strings
- IF
1 | IF(expr, val1, val2) -- val1 when expr is true, else val2 |
- IFNULL
1 | select IFNULL(expr1, expr2) -- expr2 when expr1 is NULL |
- ISNULL
1 | select ISNULL(null) |
- MID
1 | Substring: |
- LOCATE
1 | Position of a substring: |
- INSTR
1 | Like LOCATE but argument order reversed; no pos argument: |
- concat & concat_ws
1 | concat(str1, str2, [str3]...) |
- group_concat
1 | Roll column values into one string (default comma separator): |
- ELT
1 | Pick the Nth string: |
- FIND_IN_SET
1 | FIND_IN_SET(str, strlist) |
- QUOTE
1 | Escape a string for safe literal use |
- trim
1 | mysql> SELECT TRIM(' bar '); |
More to add later.
Questions? Leave a comment below or email: newbvirgil@gmail.com![]()
