title: perform a JOIN if joined field has a value
body: <p>After googling and looking on SO I came out with a not working solution for a specific type of query. I have a table that is used to convert a value from another table in a text. Let's say:</p>
  
  <pre><code>id - text
  1 - House
  2 - Villa
  3 - Camper
  </code></pre>
  
  <p>and the main table is</p>
  
  <pre><code>id - valueA - valueB - valueC
  1 - 1 - whastington - 3000
  2 -  - NewYork - 5000
  </code></pre>
  
  <p>So if I fetch row frm the main table I replace the values for valueA from 1 to House and so on. </p>
  
  <p>ValueA is set on specific conditions. In any other case it will be left blank (the field is not intended to be NULL).</p>
  
  <p>If I do the join the second row will be left out because valueA is blank. The query is </p>
  
  <pre><code>SELECT id,text,valueB,valueC FROM main JOIN dic on main.valueA =  dic.id
  </code></pre>
  
  <p>so I tried to say: <strong><em>perform the join only if valueA is not blank</em></strong>
  and I wrote this condition as:</p>
  
  <pre><code>SELECT id,text,valueB,valueC FROM main 
  JOIN dic ON (main.valueA =  dic.id AND main.valueA &lt;&gt;'')
  </code></pre>
  
  <p>as I read in <a href="https://stackoverflow.com/questions/11877218/dont-join-a-table-if-column-value-doesnt-exist">this question</a> but I did not get what I want, probably because the AND condition in that case was based on another field and not on the joined one. I can add another row in the dictionary table with a 0 - NONE couple and turn all the empty valueA to 0 but I'd like to learn if I'm on the right path with my query and what I am doing wrong. This so called "conditional join" is possible in mysql?
  I also had a look at <a href="https://stackoverflow.com/questions/8948812/mysql-conditional-join-depends-on-a-column">this question</a> but this solution would make this query too complicated for it's purpose and in this case I'd go for the "plan B" of replacing empty with 0</p>