Fixed database query

So it turns out I'm stupid and forgot how SQLite works.