Note that there are some explanatory texts on larger screens.

plurals
  1. POMYSQL join query not working
    primarykey
    data
    text
    <p>I have 2 mysql tables named </p> <ol> <li><p>blog</p></li> <li><p>comment</p></li> </ol> <p>What i am trying to do to retrieve following columns <code>user_name</code> <code>comment_desc</code> from the comment table using blog_id.</p> <p>Both the tables have blog_id in common.</p> <p>here below are the screenshots of both sql tables</p> <p>Comment Table: <img src="https://i1272.photobucket.com/albums/y386/Ahad_Murtaza/Untitled_zps3bb06ee3.png" alt="comment table"></p> <p>Blog Table: <img src="https://i1272.photobucket.com/albums/y386/Ahad_Murtaza/Untitled2_zps0055716f.png" alt="blog table"></p> <p>I tried the query this way.</p> <pre class="lang-sql prettyprint-override"><code>SELECT blog.blog_id, comment.user_name, comment.comment_desc FROM blog (b) INNER JOIN comment (c) ON b.blog_id = c.blog_id </code></pre> <p>i dont have access to upload the image thats why i uploaded to photobucket.</p> <p>The PHP Code....</p> <pre><code>&lt;?php $comments_set = blog_comments(); var_dump($comments_set); while($comments_all = mysql_fetch_assoc($comments_set)){ $name = $comments_all['user_name']; $desc = $comments_all['comment_desc']; echo "&lt;ol class=\"commentlist clearfix\"&gt; &lt;li class=\"comment even thread-even depth-1\" id=\"li-comment-1\"&gt; &lt;div id=\"comment-1\" class=\"comment-wrap clearfix\"&gt; &lt;div class=\"comment-meta\"&gt; &lt;div class=\"comment-author vcard\"&gt; &lt;span class=\"comment-avatar clearfix\"&gt; &lt;img alt='' src='http://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=60' class='avatar avatar-60 photo avatar-default' height='60' width='60' /&gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=\"comment-content clearfix\"&gt; &lt;div class=\"comment-author\"&gt;$name&lt;span&gt;&lt;a href=\"#\" title=\"Permalink to this comment\"&gt;January 24, 2013 at 10:46 am&lt;/a&gt; &amp;middot; &lt;a class='comment-reply-link' href=\"#\"&gt;Reply&lt;/a&gt;&lt;/span&gt;&lt;/div&gt; &lt;p&gt;$desc&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; "; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload