 <p>You can use <strong>ifnull</strong> function:</p> <pre><code>SELECT table1.name AS name, table1.supl AS supply, ifnull(table2.num,0) AS numbers, table1.maxnum AS maxnumbers FROM (table1 LEFT JOIN table2 ON ((table1.id = table2.id))) ORDER BY table1.name </code></pre>