kvz.io

Sql

  • Published on
    Back to basic, let's brush up on some `SQL` :) At my company we have employees creating customer accounts every day. Sometimes we make mistakes, for instance, we forget to check if the company already was a customer (maybe 10y ago they may have had a product). Duplicate accounts can cause all sorts of problems, so I wanted way to detect them with `SQL`. The problem was, the company names may have been entered with different punctuation, whitespace, etc. So I needed similar names to surface from the depths of our database, not just exact matches (that would have been too easy :)
  • Published on
    IDs are often numbers. Unfortunately there are only 10 digits to work with, so if you have a lot of records, IDs tend to get very lengthy. For computers that's OK. But human beings like their IDs as short as possible. So how can we **make IDs shorter**? Well, we could borrow characters from the alphabet as have them pose as additional numbers.... Alphabet to the rescue!
  • Published on
    Code spends more time being [read than being written](https://www.codinghorror.com/blog/archives/000684.html). I think naturally this is true for queries as well. So it might help if we teach ourselves some guidelines as how to nicely format them. I've searched but at the time of writing, could not find a public Style Guide for SQL formatting. I'll try to keep this guide short and pragmatic, so that it has a chance of actually being read & stuck to : )