title: Using LIKE inside an IF in mysql
body: <p>I'm trying to use LIKE inside an IF clause in mySQL and getting an error.</p>
  
  <pre><code>SELECT nc.web_name AS company_name,
      IF((b.booth_number LIKE '%Cafe%', b.booth_number, substring(b.booth_number,4)) AS booth_number, 
      nc.site_url AS website, IF (nc.ismi_status = 1, 'Member','') AS member_status 
      FROM booth_sale bs JOIN {ismi.booth} b ON bs.booth_id = b.booth_id 
      JOIN ismi.new_people np ON bs.contact_id = np.id 
      JOIN ismi.new_company nc ON nc.id = np.company_id 
      WHERE b.show_event_id = 298 AND status IN(44,45) ORDER BY 3
  </code></pre>
  
  <p>The query works fine if I do this:</p>
  
  <pre><code>IF((b.booth_number = 'Cafe', b.booth_number, substring(b.booth_number,4)) AS booth_number
  </code></pre>
  
  <p>But I need to check for multiple possibilities - there could be Cafe, Cafe1, Cafe2, etc. and I want to return <code>b.booth_number</code> for any record where that field value includes Cafe.</p>
  
  <p>This is the error I get:</p>
  
  <blockquote>
    <p>PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064
    You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near 'AS booth_number, nc.site_url AS website, IF (nc.ismi_status = 1,
    'Member','') ' at line 2: SELECT nc.web_name AS company_name,
    IF((b.booth_number LIKE '%Cafe%', b.booth_number,
    substring(b.booth_number,4)) AS booth_number, nc.site_url AS website,
    IF (nc.ismi_status = 1, 'Member','') AS member_status FROM
    {ismi.booth_sale} bs JOIN {ismi.booth} b ON bs.booth_id = b.booth_id
    JOIN {ismi.new_people} np ON bs.contact_id = np.id JOIN
    {ismi.new_company} nc ON nc.id = np.company_id WHERE b.show_event_id =
    298 AND status IN(44,45) ORDER BY 3</p>
  </blockquote>
  
  <p>Can anyone tell me what I'm doing wrong, or if there's another way to do this?</p>