the first of many sql query edits