Cheaper, Faster, Better!
   
 


${

   /* Generates a String that selects for when 'attribute' matches for one of the
   specified '\' delimited values. This string can be tacked onto the end of a 
   sql WHERE clause for versions of mysql that don't support 'IN' */
   
   String generateSQLInClause(String attribute, String values){
      StringBuffer qbuff = new StringBuffer();
      Tokenizer vTok = new Tokenizer(values,'|');
      String curVal;
      
      if( (curVal = vTok.next()) != null){
         if(curVal eq "*") 
            return "";
            
         qbuff.append("AND (");
         qbuff.append(attribute+ "='"+conn.escape(curVal)+"'");
   
         while((curVal = vTok.next())!=null) {
            if(curVal eq "*") 
               return "";
            qbuff.append(" OR "+attribute+"='"+conn.escape(curVal)+"'");
         }

         qbuff.append(") ");
      }
      
      return qbuff.toString();
   }
}$