title: MySQL custom global defined variable
body: <p>In my database design, I tend to store some variable that is meant to be acting as a ROLE or TYPE as <code>SMALLINT</code>.</p>
  <p>For example:</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE `house` (
     `id` int(11) NOT NULL AUTO_INCREMENT,
     `type` smallint(11) NOT NULL,
  </code></pre>
  <p>And in PHP, I do:</p>
  <pre><code>define('HOUSE_SMALL_TYPE', '0');
  define('HOUSE_MEDIUM_TYPE', '1');
  </code></pre>
  <p>So in PHP, in <code>SELECT</code> queries I do:</p>
  <pre><code>$this-&gt;db-&gt;query(&quot;SELECT * FROM house  
                    WHERE type = ?;&quot;, HOUSE_SMALL_TYPE);
  </code></pre>
  <br>
  My questions are: 
  <ol>
  <li>In the PHP part, is there is a better way to do this?</li>
  <li>In the MySQL itself, does MySQL also has global define functionality (like the define in PHP)?</li>
  </ol>
  <p>I also want to do kind of</p>
  <pre class="lang-sql prettyprint-override"><code>SELECT * FROM house  WHERE type = HOUSE_SMALL_TYPE;
  </code></pre>
  <p>in MySQL query.</p>
  <p>My purpose is that when I do SELECT in MySQL, no way I'm going to keep mapping the value 0,1,2 with its real meaning. Just convenience for viewing the tables values, without changing the structure table and fields.</p>