title: SQL CASE statement with multiple LIKE options
body: <p>I'm trying to use the USER_AGENT to determine if a user clicking my link is using a mobile device. Every click creates a row in my table, and I'm trying to insert either a "1" if the user is on mobile, or a "0" if he/she is not.</p>
  
  <p>I've come up with the following SQL statement. Would this work? Is there any way to combine all those cases into a single line, as they all result in the same value (1)? And how could I optimize this for speed? I'm open to any suggestions. Thank you!</p>
  
  <pre><code>INSERT INTO click_table(mobile_agent)
  VALUES
  (
      CASE
          when user_agent_string LIKE '%mobi%' THEN '1'
          when user_agent_string LIKE '%iphone%' THEN '1'
          when user_agent_string LIKE '%ipad%' THEN '1'
          when user_agent_string LIKE '%android%' THEN '1'
          when user_agent_string LIKE '%blackberry%' THEN '1'
          when user_agent_string LIKE '%blazer%' THEN '1'
          when user_agent_string LIKE '%bolt%' THEN '1'
          when user_agent_string LIKE '%symbianos%' THEN '1'
          when user_agent_string LIKE '%doris%' THEN '1'
          when user_agent_string LIKE '%dorothy%' THEN '1'
          when user_agent_string LIKE '%fennec%' THEN '1'
          when user_agent_string LIKE '%gobrowser%' THEN '1'
          when user_agent_string LIKE '%iemobile%' THEN '1'
          when user_agent_string LIKE '%iris%' THEN '1'
          when user_agent_string LIKE '%maemo%' THEN '1'
          when user_agent_string LIKE '%mib%' THEN '1'
          when user_agent_string LIKE '%minimo%' THEN '1'
          when user_agent_string LIKE '%netfront%' THEN '1'
          when user_agent_string LIKE '%mini%' THEN '1'
          when user_agent_string LIKE '%semc%' THEN '1'
          when user_agent_string LIKE '%skyfire%' THEN '1'
          when user_agent_string LIKE '%teashark%' THEN '1'
          when user_agent_string LIKE '%teleca%' THEN '1'
          when user_agent_string LIKE '%uzardweb%' THEN '1'
          when user_agent_string LIKE '%docomo%' THEN '1'
          when user_agent_string LIKE '%vodafone%' THEN '1'
          when user_agent_string LIKE '%playbook%' THEN '1'
          else '0'
      END
  );
  </code></pre>