etsted Posted May 14, 2014 Share Posted May 14, 2014 I have a script here that is supposed to select information from 2 databases, but it only select from one, conversation_message. $status_replies = ""; // select all the replies connected to their specific thread $sql = "SELECT conversation_message.id, conversation_message.subject, conversation_message.message, conversation_message.date_sent, conversation.sender FROM conversation_message LEFT JOIN conversation ON conversation_message.id = conversation.id ORDER BY conversation_message.date_sent ASC"; $query_replies = mysqli_query($con, $sql); $replynumrows = mysqli_num_rows($query_replies); if($replynumrows > 0){ while ($row2 = mysqli_fetch_array($query_replies, MYSQLI_ASSOC)) { $statusreplyid = $row2["id"]; $statusReplySubject = $row2["subject"]; $replydata = $row2["message"]; $statusReplySender = $row2["sender"]; $replydata = nl2br($replydata); $replydata = str_replace("&","&",$replydata); $replydata = stripslashes($replydata); $replyDate = $row2["date_sent"]; // holds all of the replies $status_replies .= '<div id="reply_'.$statusreplyid.'" class="reply_boxes"><div><b>Reply by <a href="user.php?u='.$statusReplySender.'">'.$statusReplySender.'</a> '.$replyDate.':</b><br />'.$replydata.'</div></div>'; } } $statusReplySender which comes from the conversation table dont return anything, and yes it does have a value inside the DB. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 14, 2014 Share Posted May 14, 2014 Those are tables, not databases. A left join means that all rows in the left table (conversation_message) will be returned, along with any matching rows from the right table (conversation). If it's not returning any matching rows then no rows from conversation matched the conditions in the ON clause. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now