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

  • Home
  • SEARCH
  • 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 8064741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:27:36+00:00 2026-06-05T11:27:36+00:00

This question is how to go about selecting multiple rows from a table using

  • 0

This question is how to go about selecting multiple rows from a table using a range of values in the WHERE clause. Here is what I am trying to do.

I have a commenting application in which you post a comment and your friends can respond to it, sort of like facebook’s wall. And in the same application I allow each member to be friends with one another.

My challenge now is that instead of just showing the owner’s comments, I want to show their friends as well. I want a similar functionality as facebook’s wall.
So here is what I have:

    Friends Table                           Commenting Table
 _______________________        ___________________________________________
| member_id | friend_id |      | member_id |           comment             |
 -----------------------        -------------------------------------------
|    10     |    14     |      |    10     |      Hello member # 14        |
|    14     |    10     |      |    14     |      hey how are you          |
|    17     |    9      |      |    17     |      Hello world              |
|    17     |    10     |      |    10     |      Hello                    |
 ------------------------       --------------------------------------------

so member 10 is friends with member 14 and 17. And instead of just showing the comments for member 10, I want to show the comments of member 10, 14, and 17. Like this:

        Member Comments                          All Member Comments
 _______________________________        ___________________________________________
| member_id |      comment      |      | member_id |           comment             |
 -------------------------------        -------------------------------------------
|    10     | Hello member # 14 |      |    10     |      Hello member #           |
|    10     |       Hello       |      |    14     |      hey how are you          |
---------------------------------      |    17     |      Hello world              |
                                       |    10     |      Hello                    |
                                       --------------------------------------------

So i was trying mysql_query(“SELECT comments Commenting Table WHERE member_id = ’10’ ORDER BY member_id DESC”) and do a bunch of while loops but thats not very efficient. Is there any other way of selecting the comments using multiple values?

  • 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-05T11:27:37+00:00Added an answer on June 5, 2026 at 11:27 am

    You can join the tables by the friend’s id and the member’s id and afterwards group by the member id:

    SELECT f.member_id AS user, c.member_id AS commentBy, c.comment AS comment
    FROM commentingTable AS c, friendsTable AS f
    WHERE c.member_id = f.member_id 
      OR c.member_id = f.friend_id
    GROUP BY f.member_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var playerClass = $(this).parent().attr('class') Question about only selecting a specific class from the dom.
I have seen this question about deploying to WebSphere using the WAS ant tasks.
From my previous question for selecting specific html text, I have gone through this
This is related to my previous question about selecting visible elements . Now, here's
I have a basic question about selecting counts: If I have a table ContentTable
This question about Timers for windows services got me thinking: Say I have (and
I've this question about pass some instances by ref or not: here is my
This is likely a novice question about LINQ, but assuming I have a set
I have been reading on the different question talking about selecting unique nodes in
I already asked a question about this yesterday, but now I have another :)

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.