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?