about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/database.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/database.c b/src/database.c
index 340f59b2..714c4b1a 100644
--- a/src/database.c
+++ b/src/database.c
@@ -212,7 +212,7 @@ log_database_get_previous_chat(const gchar *const contact_barejid)
 	sqlite3_stmt *stmt = NULL;
     char *query;
 
-    if (asprintf(&query, "SELECT `message`, `timestamp`, `from_jid` from `ChatLogs` WHERE `from_jid` = '%s' OR `to_jid` = '%s' ORDER BY `timestamp` ASC LIMIT 10", contact_barejid, contact_barejid) == -1) {
+    if (asprintf(&query, "SELECT * FROM (SELECT `message`, `timestamp`, `from_jid` from `ChatLogs` WHERE `from_jid` = '%s' OR `to_jid` = '%s' ORDER BY `timestamp` DESC LIMIT 10) ORDER BY `timestamp` ASC;", contact_barejid, contact_barejid) == -1) {
         log_error("log_database_get_previous_chat(): SQL query. could not allocate memory");
         return NULL;
     }