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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:00:35+00:00 2026-05-17T01:00:35+00:00

I have two columns, senderUserID and recieverUserID in Messages table. I select senderUserID and

  • 0

I have two columns, senderUserID and recieverUserID in Messages table.
I select senderUserID and recieverUserID where current receiver sent a message to current sender in the past. I select 10 rows only each time but sometimes in this table senderUserID appears more than once when i need that only senderUserID will be unique, while recieverUserID can return as many times as it happens.

this is sample data

66622   61350
90166   79222
90176   79222
86727   80452
10888   47305
66560   79219
66622   80452
89548   14452
66622   69177
52081   79223

as you can see 66622 appears twice in senderUserID. How do i limit it to appears only once.

thanks

  • 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-05-17T01:00:36+00:00Added an answer on May 17, 2026 at 1:00 am

    I’d say just ignore any duplicates. That will give you less than ten results for each of your batches, but I’d prefer that to enforcing uniqueness via grouping on the database (could be expensive). The objective here is to maximize message throughput, right?

    If you still want to do it in SQL:

     select senderUserId, max(receiverUserId) from messages group by senderUserId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two columns: SELECT b.ip_address AS IP ,b.mask AS MASK FROM
I have two tables in my database: NEWS table with columns: id - the
I have a table y Which has two columns a and b Entries are:
I have two columns in my Items table 'Category', 'Category2', the two columns contain,
I have two columns in the table hours at sea - Would be good
I have two columns in Excel, like this: A B 0.5 0.4 0.6 0.59
I have two tables with the same columns, and I need to copy one
I have two tables with the following columns: table1: id, agent_name, ticket_id, category, date_logged
I have two tables with the same columns tbl_source (ID, Title) tbl_dest (ID, Title)
I have a listview with two columns and I'm using a context menu to

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.