First attempt at making SQL queries less ugly