Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7706169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:03:14+00:00 2026-06-01T00:03:14+00:00

I have created an inbox system. Signed in user can message other signed in

  • 0

I have created an inbox system. Signed in user can message other signed in users. The usermessage Table from database has two fields 1. userid and 2. messageid. The following is an excerpt from this table.

userid | messageid
12     | 1
13     | 1
14     | 2
15     | 2
12     | 3
15     | 3
12     | 4
14     | 4

In above situation when user ’12’ send message to user ’13’. I want the messageid ‘1’ to move to bottom of the table so that when the user ’12’ or ’13’ is checking his mailbox, the messageid ‘1’ needs to appear on the top of inbox as a recent conversation. So far I have been able to achieve this by deleting the messageid ‘1’ and inserting as a new query for each userid. This is my code:

DELETE FROM usermessage WHERE userid = '12' and messageid = '1';
INSERT INTO usermessage SET userid = '12', messageid = '1';
DELETE FROM usermessage WHERE userid = '13' and messageid = '1';
INSERT INTO usermessage SET userid = '13', messageid = '1';

Is it possible get this done with one query. So far, I was not able to find any definite answer in stackflow related to my problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:03:15+00:00Added an answer on June 1, 2026 at 12:03 am

    Querying rows without SORT statement gives no guaranties that they will be sorted in the created time order. Its is just a chance that MySQL gives you such a sorting behavior since now.

    So it is necessary that you found or create an objective sorting rule. It can be the timestamp of the message, or a new timestamp column in you [usermessage] table.

    It is also noticeable that deleting and re-creating rows will affect the MySQL process cost because MySQL will need to update the indexes on [usermessage] table each time you delete and insert.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have created a user message page with this plugin. The grid will
On my user inbox from my user messaging system I am building a feature
I have created a UserControl that has a ListView in it. The ListView is
I have created a few small flash widgets that stream .mp3 audio from an
I have created a foreign key (in SQL Server) by: alter table company add
Am creating a messaging system model after facebook's messages. The message inbox is threaded,
I have a folder called Datas. This folder has a subfolder called Inbox inside
I have created a list of contact's in user phone, now i want to
I have a strange requirement, any website user(not linux system user) will be getting
I have made an application recently which has articles, etc, with a commenting/moderation system

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.