SMS database querying