Note that there are some explanatory texts on larger screens.

plurals
  1. POmysql result not displaying based on my query
    primarykey
    data
    text
    <p>I have a table called <code>add_project</code>:</p> <pre> +------------+---------+-------------------+--------------+ | project_id | user_id | project_status_id | project_name | +------------+---------+-------------------+--------------+ | 1 | 1 | 3 | abc | | 2 | 1 | 0 | def | | 3 | 1 | 1 | xyz | | 4 | 1 | 3 | lmn | | 5 | 1 | 0 | trs | | 6 | 1 | 3 | ght | +------------+---------+-------------------+--------------+ </pre> <p>Here on this table admin add the new projects. The admin <code>user_id</code> is 1 so it is all common. <code>project_status_id</code> indicates the completion status of that project (0=new, 1=working, 3=completed).</p> <p>And I have another table called <code>asign_project</code>:</p> <pre> +----------+------------+---------+ | asign_id | project_id | user_id | +----------+------------+---------+ | 1 | 1 | 5 | | 2 | 5 | 9 | | 3 | 2 | 5 | | 4 | 4 | 5 | | 5 | 6 | 9 | | 6 | 3 | 9 | +----------+------------+---------+ </pre> <p>Here on this table the admin assigns the project to different users.</p> <p>Now what I want is to find how many completed projects each user has done. As you can see, <code>project_id(1,4)</code> has been completed by <code>user_id=5</code>.</p> <p>So my question is how do I get that value?</p> <p>Below is the query that I have written:</p> <pre class="lang-sql prettyprint-override"><code>SELECT * FROM asign_project, add_project WHERE asign_project.project_id = add_project.project_id AND project_status_id='3' AND user_id='5' </code></pre> <p>But it is showing:</p> <blockquote> <p><code>#1052 - Column 'user_id' in where clause is ambiguous</code></p> </blockquote> <p>See it on <a href="http://sqlfiddle.com/#!2/2f8e3b/1" rel="nofollow">sqlfiddle</a>.</p> <p>Waiting for your reply.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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