title: MySql- Select DISTINCT value from three tables
body: <p>I have three tables and I want to SELECT DISTINCT * from table1 and cat from table2 of those whose vid is available in table3.</p>
  
  <p><b>Table1</b></p>
  
  <pre><code>id      fname       area       price
  
  1       ABC         Mall R     1500
  2       ABd         Mall a     1400
  3       ABe         Mall f     1200
  4       ABt         Mall b     1000
  </code></pre>
  
  <p><b>Table2</b></p>
  
  <pre><code>id      catid       cat
  
  1         2         xy
  2         2         yz
  3         1         yxx
  4         4         ytt
  5         3         xy
  </code></pre>
  
  <p><b>Table3</b></p>
  
  <pre><code>id       vid
  
  1         2
  2         1
  3         4
  </code></pre>
  
  <p>So far what i have tried is</p>
  
  <pre><code>SELECT * FROM Table1,Table2,Table3 
  WHERE 
  Table1.id=Table2.catid AND
  Table1.id=Table3.vid;
  </code></pre>
  
  <p><b>Output i am getting</b></p>
  
  <pre><code>id      fname       area       price     cat
  
  1       ABC         Mall R     1500      yxx
  2       ABd         Mall a     1400      xy
  2       ABd         Mall a     1400      yz
  4       ABt         Mall b     1000      ytt
  </code></pre>
  
  <p><b>Desired Output</b></p>
  
  <pre><code>id      fname       area       price     cat
  
  1       ABC         Mall R     1500      yxx
  2       ABd         Mall a     1400      xy
  4       ABt         Mall b     1000      ytt
  </code></pre>
  
  <p>I want to select details of ID 2 just once doesn't matter it takes cat from Table2 "xy or yz". </p>
  
  <p>Thanks....</p>