title: MySQL query - how can we select a multi column in specific value over 3 tables
body: <p>I have the following tables in my database:  </p>
  
  <ol>
  <li>clients (table name = 'reps')  </li>
  <li>projects (table name = 'verkocht')</li>
  <li>milestones (table name = 'milestones')</li>
  </ol>
  
  <p>Client X has 300 projects. 200 of them does not have milestones. 100 of them has milestones. I get right now all 300 projects. my goal is getting 100 projects. If a project does not have a milestone, then why would I show that project?</p>
  
  <p>My goal is getting <strong>only</strong> all projects which have milestones.</p>
  
  <p>I tried this but did not work:</p>
  
  <pre><code>SELECT DISTINCT `clients` 
  FROM reps c
  INNER JOIN verkocht p ON p.client = c.clients
  INNER JOIN milestones m ON m.verkocht_id = p.id
  GROUP BY p.id
  </code></pre>
  
  <p>I also tried this:</p>
  
  <pre><code>SELECT * 
  FROM `reps` 
  WHERE `clients` IN (SELECT * 
                      FROM `milestones` 
                      WHERE `client` = 'X')
  </code></pre>
  
  <p>My query of projects is this:</p>
  
  <pre><code>$clientValue = $_COOKIE['client'];
  $queryProject = " SELECT `id`, `beschrijving`, `client` FROM `verkocht` WHERE `beschrijving` != '' AND `client` = '{$clientValue}' ";
  </code></pre>
  
  <p>Example: If I select client 'stackoverflow' I can choose 200 projects. If i click on project 129 I see nothing because project 129 has no milestones. It makes no sense when I select a project with has no milestone. that is why I want to select project which <strong>has</strong> milestones</p>
  
  <p><strong>EDIT</strong>: added database tables</p>
  
  <p>Table 'reps'</p>
  
  <pre><code>        1   ID             int(5)       AUTO_INCREMENT  
          2   clients        tinytext
  </code></pre>
  
  <p>Table 'verkocht'</p>
  
  <pre><code>        1   ID             int(11)      AUTO_INCREMENT  
          2   client         varchar(130)  
          4   beschrijving   tinytext
  </code></pre>
  
  <p>Table 'milestones'</p>
  
  <pre><code>        1   ID             int(11)      AUTO_INCREMENT  
          2   titel          varchar(64) 
          4   omschrijving   text
          5   client         varchar(40)
          6   verkocht_id    int(11)
  </code></pre>