title: Mysql search multiple tables and limit to 1
body: <p>I have 4 tables:</p>
  
  <p>Artists:</p>
  
  <pre><code>id  name
  1   Band
  2   DJ
  </code></pre>
  
  <p>Genres:</p>
  
  <pre><code>id  artist_id  genre_id
  1   1          2
  2   1          3
  3   2          2
  </code></pre>
  
  <p>Categories:</p>
  
  <pre><code>id  artist_id  category_id
  1   1          1
  2   1          2
  3   2          3
  </code></pre>
  
  <p>Prices:</p>
  
  <pre><code>id  artist_id  price  time
  1   1          120    60
  1   1          400    240
  </code></pre>
  
  <p>What I need is to use a keyword for searching in the name with a genre and category. And i need the lowest price.</p>
  
  <p>So when I request this:</p>
  
  <p>keyword: "band"
  category: "1"
  genre: "2"</p>
  
  <p>the result should be:</p>
  
  <pre><code>Band  120
  </code></pre>
  
  <p>It should also ordered by name or by price.</p>
  
  <p>I have this right now, but it returns multiple artists when they have multiple categories or genres.</p>
  
  <pre><code>SELECT * FROM artists
             LEFT JOIN artists_genres ON artists_genres.artist_id = artists.id 
             LEFT JOIN artists_categories ON artists_categories.artist_id = artists.id 
             LEFT JOIN artists_prices ON artists_prices.artist_id = artists.id 
             WHERE genre_id = $genre AND category_id = $cat AND name LIKE '%$keyword%'
  </code></pre>