Log in

View Full Version : Querying two tables help



Xcalibre
03-30-2012, 11:48 AM
Hey all...new here.

I"ve struggled with this for hours now. I always try and find the answers before I post, so I hope someone can help me.

I'm trying to pull four fields from two different tables in my database. I"m working on a feature that allows people to post in other members areas.

the outline would be:

Posted by "username"...."date created"....."comment"

I have two tables that hold this information. I think that I have to use the user id from table one that holds the actual users ID and make it equal to the other table that holds the userID that posted the comment. That way the two ID's will match in the output.

So I have two tables... one for members....and one for posts...


members table holds:
1. user_id



posts table holds:
1. user_id
2. post_id
3. date_created

Now how in the world would I call all of this out of the database in one query? LOL. If I can do that, then I should be able to just <?php echo everything where I want it.

Thanks for any help and direction.

james438
03-30-2012, 04:22 PM
Would you be able to reword and further organize your last post? The table formats you have are helpful, but seem to be lacking. For example:

1. The members table has only one column? That seems rather unusual to me.
2. What table has the column for the posts?
3. What table has the column for the users names?

Post that information and I think I can help you.

james438
03-31-2012, 03:23 PM
Actually, I think I have all of the information I need. When I get home tonight I'll try to post something.

james438
04-01-2012, 03:32 AM
Sorry, but the more I look at your post the less I understand. I really need you to rephrase and clarify what it is that you want. Please address my earlier questions as well as this sentence:


I"m working on a feature that allows people to post in other members areas.