title: MySQL 5.0 reporting "concat does not exist"
body: <p>I have a query with a complex concatenation in it. It's something along the lines of concatenating the results of several sub-selects if the results are not null. It works fine (though the complexity makes me a little sick) on our development server which runs MySQL 5.1 but our production server, which runs 5.0 reports </p>
  
  <pre><code>FUNCTION database.concat does not exist
  </code></pre>
  
  <p>Any ideas why this might be? Upgrading is unfortunately not an option at this point so unless someone has a bright idea I'm pretty much stuck rewriting this report.</p>
  
  <p>Query is as follows (Yes I realize I'm horribly abusing mysql. Let's set that aside for now. If anyone knows how of a way to refer to a subselect by alias that would be handy, but I've never been able to do it, hence the repeated subselect. Also concat returns <code>NULL</code> if any of  the arguments are <code>NULL</code>, hence the if statements.)</p>
  
  <pre class="lang-sql prettyprint-override"><code>select (concat(if((select 
                         concat(if(b.foo is not null, b.foo, ""), 
                         " ", 
                         if(f.bar is not null, f.bar, ""))
                       from  `foo_table`  as f
                        left join `bar_table` as b
                          on b.SOME_ID = f.SOME_ID
                       where f.STUDENT_ID = t.STUDENT_ID
                         and bar.NewID = t.OldID order by bar.id limit 1) is not null,
                     (select 
                        concat(if(b.foo is not null, b.foo, ""), 
                         " ", 
                         if(f.bar is not null, f.bar, ""))
                       from  `foo_table`  as f
                        left join `bar_table` as b
                          on b.SOME_ID = f.SOME_ID
                       where f.STUDENT_ID = t.STUDENT_ID
                         and bar.NewID = t.OldID order by bar.id limit 1),
                     ""),
         " ",
         t.reason) as Reason
     from table as t
  </code></pre>