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 8008135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:02:50+00:00 2026-06-04T18:02:50+00:00

I need to select last record from each conversation between 2 users My table:

  • 0

I need to select last record from each conversation between 2 users

My table:

id | sender_id | recipient_id | message
1     2           3              msg_1 
2     3           2              msg_2
4     2           3              msg_4
5     2           3              msg_5
7     4           3              msg_7
8     3           4              msg_8

After select it should find this records

id | sender_id | recipient_id | message 
5     2           3              msg_5
8     3           4              msg_8
  • 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-04T18:02:52+00:00Added an answer on June 4, 2026 at 6:02 pm
    SELECT  m.*
    FROM    mytable m
    WHERE   id = ( SELECT   MAX(id)
               FROM     mytable
               WHERE    ( sender_id = m.sender_Id
                          OR recipient_id = m.sender_id
                        )
                        AND ( recipient_id = m.recipient_Id
                              OR sender_id = m.recipient_id
                            )
             )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to select only 20 records from the table and than add pagination
I need to select all from table1 where active=1 and replace t1cid,t2cid,L1cid,L2cid---L10cid with corresponding
I need to select all entries between two given dates (Nov 10 and Jan
I need to add a select box next to each field in a create/update
I need to retrieve data from these 3 tables users +----------+-----------+ | username |
I need to select the counts from two tables that share a common column
I have a table that will have 500,000+ records. Each record has a LineNumber
This is a follow up on another problem i had with getting-the-last-record-inserted-into-a-select-query I am
I have a Users table and a Payments table. I need a query which
We need to store a list of data we pull from another table that

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.