I have no idea what to call what I'm trying to do, but I can explain it quite well. I have two tables with the following structure in my WebSQL database. This is being used in my mobile application (Hybrid app) to keep storage of user messages. These are my tables:
message_threads [ thread_id, user_id, last_seen, last_active ]
messages [ message_id, thread_id, message_type, message_content, message_date ]
I already have all of the logic handled for adding messages to the database, and creating new message threads, but the problem I have is ordering them when trying to retrieve them.
I would like to order my results (of messages) by the last_active field of the message_thread with the corresponding thread_id. However, now that I've done that, I also want to order all of the messages for that thread by the message's message_date field.
So, basically, I want to group all of my messages by their thread, order the thread by the last_active field, then order the messages inside of that thread by the message_date field. I assume there's a way to do this in SQLite, and if not I can just do a lot of loop logic on the front-end, which really won't hurt anything, but it's always nice to know the tricks of the query language.
Aucun commentaire:
Enregistrer un commentaire