diff --git a/src/ssb.db.c b/src/ssb.db.c index 7841c544..0d4d3375 100644 --- a/src/ssb.db.c +++ b/src/ssb.db.c @@ -981,7 +981,7 @@ bool tf_ssb_db_get_latest_message_by_author(tf_ssb_t* ssb, const char* author, i bool found = false; sqlite3_stmt* statement; sqlite3* db = tf_ssb_acquire_db_reader(ssb); - const char* query = "SELECT id, sequence FROM messages WHERE author = ?1 AND sequence = (SELECT MAX(sequence) FROM messages WHERE author = ?1)"; + const char* query = "SELECT id, sequence FROM messages WHERE author = ?1 ORDER BY sequence DESC LIMIT 1"; if (sqlite3_prepare(db, query, -1, &statement, NULL) == SQLITE_OK) { if (sqlite3_bind_text(statement, 1, author, -1, NULL) == SQLITE_OK && sqlite3_step(statement) == SQLITE_ROW)