Jump to content

Recommended Posts

SELECT * FROM tbl_comments WHERE

 

the post they commented is a post from the user

 

the table tbl_comments has just the post_id of the post they are commenting

 

the tbl_posts has the user_id of the person who made the post.

 

PLEASE HELP i know theres a way to select them at the same time i just never understood it.

Link to comment
https://forums.phpfreaks.com/topic/202667-selecting-from-2-databases-at-once/
Share on other sites

2 different databases? OR 2 different tables?

 

Your post has 3 tables.

$sql = "SELECT a.*,b.title,c.user 
               FROM tbl_comments AS a 
               LEFT JOIN tbl_posts AS b ON a.post = b.id 
               LEFT JOIN user AS c ON c.id = b.user 
               WHERE c.username = 'jwk811'";

yes tables and its actually 2 tables. the post table has the user id in it already. and i dont understand how that works:

 

$sql = "SELECT a.*,b.title,c.user

              FROM tbl_comments AS a

              LEFT JOIN tbl_posts AS b ON a.post = b.id

              LEFT JOIN user AS c ON c.id = b.user

              WHERE c.username = 'jwk811'";

 

thank you for your help though, i will go from there =]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.