Blog

DATABASE Study Notes

Published 1 min read

  1. When NULL, print something else - IFNULL(column name, 'content')
  2. Print date only - DATE_FORMAT(column name, '%Y-%m-%d')
  3. Contains string - LIKE '%STRING%', (% is a wildcard)
  4. Average - AVG(column)
  5. Decimals - round(decimal) = rounds to an integer, round(decimal, digits) = prints rounded to that many digits
  6. TRUNCATE function - just see this blog
  7. Not-equal operator - <> (same as !=)
  8. LIMIT a - print a rows from the start
  9. LIMIT a b - print from row a+1 to row b
  10. DATEDIFF(end, start): returns the DATE difference expressed in 'DAY'
  11. DATESTAMPDIFF(unit, start, end): returns the DATE difference in the given unit
  12. Remove duplicates: DISTINCT field name
  13. number, DATE BETWEEN A AND B
  14. LEFT(string, len): returns the string cut to len from the start
  15. RIGHT(string, len): omitted

[SQL] The difference between WHERE and HAVING

Comments

Leaving a comment stores your nickname (or GitHub profile info). Privacy policy

GitHub