- When NULL, print something else - IFNULL(column name, 'content')
- Print date only - DATE_FORMAT(column name, '%Y-%m-%d')
- Contains string - LIKE '%STRING%', (% is a wildcard)
- Average - AVG(column)
- Decimals - round(decimal) = rounds to an integer, round(decimal, digits) = prints rounded to that many digits
- TRUNCATE function - just see this blog
- Not-equal operator - <> (same as !=)
- LIMIT a - print a rows from the start
- LIMIT a b - print from row a+1 to row b
- DATEDIFF(end, start): returns the DATE difference expressed in 'DAY'
- DATESTAMPDIFF(unit, start, end): returns the DATE difference in the given unit
- Remove duplicates: DISTINCT field name
- number, DATE BETWEEN A AND B
- LEFT(string, len): returns the string cut to len from the start
- RIGHT(string, len): omitted
DATABASE Study Notes
Published 1 min read
Comments
Leaving a comment stores your nickname (or GitHub profile info). Privacy policy