<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A Little Noise</title>
	<atom:link href="http://thenoyes.com/littlenoise/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://thenoyes.com/littlenoise</link>
	<description></description>
	<lastBuildDate>Sat, 10 Dec 2011 16:12:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>MidPoint of a LineString</title>
		<link>http://thenoyes.com/littlenoise/?p=183</link>
		<comments>http://thenoyes.com/littlenoise/?p=183#comments</comments>
		<pubDate>Sat, 10 Dec 2011 16:12:03 +0000</pubDate>
		<dc:creator>snoyes</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://thenoyes.com/littlenoise/?p=183</guid>
		<description><![CDATA[CREATE FUNCTION MidPoint(ls LINESTRING) RETURNS POINT DETERMINISTIC BEGIN DECLARE len double; DECLARE workLength double DEFAULT 0; DECLARE workPoint int DEFAULT 1; DECLARE point0 POINT; DECLARE point1 POINT; DECLARE distanceOver double; DECLARE segmentLength double; IF (NumPoints(ls) = 1) THEN return PointN(ls, 1); END IF; -- find half the length of the linestring SET len := GLength(ls) [...]]]></description>
			<content:encoded><![CDATA[<p><code>CREATE FUNCTION MidPoint(ls LINESTRING)<br />
RETURNS POINT<br />
DETERMINISTIC<br />
BEGIN<br />
  DECLARE len double;<br />
  DECLARE workLength double DEFAULT 0;<br />
  DECLARE workPoint int DEFAULT 1;<br />
  DECLARE point0 POINT;<br />
  DECLARE point1 POINT;<br />
  DECLARE distanceOver double;<br />
  DECLARE segmentLength double;</p>
<p>  IF (NumPoints(ls) = 1) THEN return PointN(ls, 1); END IF;</p>
<p>  -- find half the length of the linestring<br />
  SET len := GLength(ls) / 2;</p>
<p>  -- walk the linestring until we exceed the distance<br />
  WHILE (workLength < len) DO<br />
    SET point0 = PointN(ls, workPoint);<br />
    SET workPoint := workPoint + 1;<br />
    SET point1 = PointN(ls, workPoint);<br />
    SET segmentLength = GLength(LineString(point0, point1));<br />
    SET workLength := workLength + segmentLength;<br />
  END WHILE;</p>
<p>  -- distance to backup<br />
  SET distanceOver = workLength - len;</p>
<p>  -- midpoint is distanceOver back down the last segement<br />
  RETURN POINT(<br />
      X(point1) - distanceOver / segmentLength * (X(point1) - X(point0)),<br />
      Y(point1) - distanceOver / segmentLength * (Y(point1) - Y(point0))<br />
    );</p>
<p>END</code></p>
]]></content:encoded>
			<wfw:commentRss>http://thenoyes.com/littlenoise/?feed=rss2&#038;p=183</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quiz: A More Perfect UNION</title>
		<link>http://thenoyes.com/littlenoise/?p=167</link>
		<comments>http://thenoyes.com/littlenoise/?p=167#comments</comments>
		<pubDate>Wed, 09 Nov 2011 20:59:03 +0000</pubDate>
		<dc:creator>snoyes</dc:creator>
				<category><![CDATA[MySQL Gotchas]]></category>

		<guid isPermaLink="false">http://thenoyes.com/littlenoise/?p=167</guid>
		<description><![CDATA[Today I saw a query like this: SELECT d FROM t; Performance was terrible. I ran out of patience after several minutes and killed the thread. I changed the query to this: (SELECT d FROM t) UNION ALL (SELECT NULL LIMIT 0); It completed in under 3 seconds. Can you explain how a no-op UNION [...]]]></description>
			<content:encoded><![CDATA[<p>Today I saw a query like this:<br />
<code>SELECT d FROM t;</code></p>
<p>Performance was terrible. I ran out of patience after several minutes and killed the thread. </p>
<p>I changed the query to this:<br />
<code>(SELECT d FROM t) UNION ALL (SELECT NULL LIMIT 0);</code></p>
<p>It completed in under 3 seconds.</p>
<p>Can you explain how a no-op UNION so dramatically improved performance? (I couldn't have, without help from Jesper Krogh and James Day).</p>
<p><a href='javascript:void(null);' onclick="s_toggleDisplay(document.getElementById('SID1375088845'), this, 'Hint #1 &#9660;', 'Hide Hint &#9650;');">Hint #1 &#9660;</a></p>
<div id='SID1375088845' style='display:none;'>
<p>http://dev.mysql.com/doc/refman/5.5/en/cursor-restrictions.html</p>
</div>
<p><a href='javascript:void(null);' onclick="s_toggleDisplay(document.getElementById('SID626394325'), this, 'Hint #2 &#9660;', 'Hide Hint &#9650;');">Hint #2 &#9660;</a></p>
<div id='SID626394325' style='display:none;'>
The field `d` is a varchar and is bigger than it needs to be.
</div>
<p><a href='javascript:void(null);' onclick="s_toggleDisplay(document.getElementById('SID1921997950'), this, 'Hint #3 &#9660;', 'Hide Hint &#9650;');">Hint #3 &#9660;</a></p>
<div id='SID1921997950' style='display:none;'>
<p>http://dev.mysql.com/doc/refman/5.5/en/memory-storage-engine.html</p>
</div>
<p><a href='javascript:void(null);' onclick="s_toggleDisplay(document.getElementById('SID2053416281'), this, 'Hint #4 &#9660;', 'Hide Hint &#9650;');">Hint #4 &#9660;</a></p>
<div id='SID2053416281' style='display:none;'>
<p>http://dev.mysql.com/doc/refman/5.5/en/internal-temporary-tables.html</p>
</div>
<p><a href='javascript:void(null);' onclick="s_toggleDisplay(document.getElementById('SID206374380'), this, 'Answer &#9660;', 'Hide Answer &#9650;');">Answer &#9660;</a></p>
<div id='SID206374380' style='display:none;'>
The query is in a cursor. MySQL materializes cursors to a temporary table, using the MEMORY engine if it can, then converting to MyISAM if it gets too big. The MEMORY engine doesn't support variable length rows, so VARCHARs are converted to CHARs. The field `d` only contains one character in each row, but is defined as a VARCHAR(20000) - which means the temporary table will grow very large. Even when converted to MyISAM, it retains that fixed width format, so the temp table is huge.</p>
<p>The "presence of any column larger than 512 bytes in the SELECT list, if UNION or UNION ALL is used," prevents use of an in-memory temporary table. That means the temporary table will be created directly as MyISAM on the disk, and will keep the VARCHAR format, so it will be much smaller. Converting the field to TEXT would have the same effect.
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://thenoyes.com/littlenoise/?feed=rss2&#038;p=167</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Yet another way to count occurences of a substring in a string</title>
		<link>http://thenoyes.com/littlenoise/?p=162</link>
		<comments>http://thenoyes.com/littlenoise/?p=162#comments</comments>
		<pubDate>Wed, 12 Oct 2011 16:20:16 +0000</pubDate>
		<dc:creator>snoyes</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://thenoyes.com/littlenoise/?p=162</guid>
		<description><![CDATA[In response to http://forge.mysql.com/snippets/view.php?id=60 - adding support to count strings, not just characters ( character_length(&#60;string1&#62;) - character_length(REPLACE(&#60;string1&#62;, &#60;searchString&#62;, '') ) / character_length(&#60;searchString&#62;)]]></description>
			<content:encoded><![CDATA[<p>In response to http://forge.mysql.com/snippets/view.php?id=60 - adding support to count strings, not just characters</p>
<pre>(
  character_length(&lt;string1&gt;)
  - character_length(REPLACE(&lt;string1&gt;, &lt;searchString&gt;, '')
) / character_length(&lt;searchString&gt;)</pre>
]]></content:encoded>
			<wfw:commentRss>http://thenoyes.com/littlenoise/?feed=rss2&#038;p=162</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easter date</title>
		<link>http://thenoyes.com/littlenoise/?p=160</link>
		<comments>http://thenoyes.com/littlenoise/?p=160#comments</comments>
		<pubDate>Wed, 12 Oct 2011 16:19:29 +0000</pubDate>
		<dc:creator>snoyes</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://thenoyes.com/littlenoise/?p=160</guid>
		<description><![CDATA[Finds the date for Easter (Western) given a year. Sample usage: SELECT easter(YEAR(NOW())); DELIMITER // CREATE FUNCTION easter(inYear YEAR) RETURNS DATE DETERMINISTIC BEGIN DECLARE a, b, c, d, e, k, m, n, p, q INT; DECLARE easter DATE; SET k = FLOOR(inYear / 100); SET a = MOD(inYear, 19); SET b = MOD(inYear, 4); SET [...]]]></description>
			<content:encoded><![CDATA[<p>Finds the date for Easter (Western) given a year.<br />
Sample usage: SELECT easter(YEAR(NOW()));</p>
<pre>DELIMITER //
CREATE FUNCTION easter(inYear YEAR) RETURNS DATE DETERMINISTIC
BEGIN
    DECLARE a, b, c, d, e, k, m, n, p, q INT;

    DECLARE easter DATE;

    SET k = FLOOR(inYear / 100);
    SET a = MOD(inYear, 19);
    SET b = MOD(inYear, 4);
    SET c = MOD(inYear, 7);
    SET q = FLOOR(k / 4);
    SET p = FLOOR((13 + 8 * k) / 25);
    SET m = MOD((15-p+k-q), 30);
    SET d = MOD((19 * a + m), 30);
    SET n = MOD((4+k-q), 7);
    SET e = MOD((2*b+4*c+6*d+n), 7);

    SET easter = CASE
        WHEN d + e <= 9 THEN CONCAT_WS('-', inYear, '03', 22 + d + e)
        WHEN d = 29 AND e = 6 THEN CONCAT_WS('-', inYear, '04-19')
        WHEN d = 28 AND e = 6 AND a > 10 THEN CONCAT_WS('-', inYear, '04-18')
        ELSE CONCAT_WS('-', inYear, '04', LPAD(d + e - 9, 2, 0))
    END;

    RETURN easter;
END
//
DELIMITER ;</pre>
]]></content:encoded>
			<wfw:commentRss>http://thenoyes.com/littlenoise/?feed=rss2&#038;p=160</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show all grants</title>
		<link>http://thenoyes.com/littlenoise/?p=158</link>
		<comments>http://thenoyes.com/littlenoise/?p=158#comments</comments>
		<pubDate>Wed, 12 Oct 2011 16:18:51 +0000</pubDate>
		<dc:creator>snoyes</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://thenoyes.com/littlenoise/?p=158</guid>
		<description><![CDATA[A stored procedure to show all grants in the database. USE mysql; DELIMITER // CREATE PROCEDURE showAllGrants() BEGIN DECLARE done INT DEFAULT 0; DECLARE theUser CHAR(16); DECLARE theHost CHAR(60); DECLARE cur1 CURSOR FOR SELECT user, host FROM mysql.user; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; OPEN cur1; REPEAT FETCH cur1 INTO theUser, [...]]]></description>
			<content:encoded><![CDATA[<p>A stored procedure to show all grants in the database.</p>
<pre>USE mysql;

DELIMITER //
CREATE PROCEDURE showAllGrants() BEGIN
    DECLARE done INT DEFAULT 0;
    DECLARE theUser CHAR(16);
    DECLARE theHost CHAR(60);
    DECLARE cur1 CURSOR FOR SELECT user, host FROM mysql.user;
    DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
    OPEN cur1;

    REPEAT
        FETCH cur1 INTO theUser, theHost;
        IF NOT done THEN
            SET @sql := CONCAT('SHOW GRANTS FOR ', QUOTE(theUser), '@', QUOTE(theHost));
            PREPARE grantStatement FROM @sql;
            EXECUTE grantStatement;
            DROP PREPARE grantStatement;
        END IF;
    UNTIL done END REPEAT;

    CLOSE cur1;
END//
DELIMITER ;

CALL showAllGrants();</pre>
]]></content:encoded>
			<wfw:commentRss>http://thenoyes.com/littlenoise/?feed=rss2&#038;p=158</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Roman numerals</title>
		<link>http://thenoyes.com/littlenoise/?p=156</link>
		<comments>http://thenoyes.com/littlenoise/?p=156#comments</comments>
		<pubDate>Wed, 12 Oct 2011 16:18:20 +0000</pubDate>
		<dc:creator>snoyes</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://thenoyes.com/littlenoise/?p=156</guid>
		<description><![CDATA[Convert an integer in the range 0 to 3999 to Roman numerals. CREATE FUNCTION `toRoman`(inArabic int unsigned) RETURNS varchar(15) CHARSET latin1 DETERMINISTIC BEGIN DECLARE numeral CHAR(7) DEFAULT 'IVXLCDM'; DECLARE stringInUse CHAR(3); DECLARE position tinyint DEFAULT 1; DECLARE currentDigit tinyint; DECLARE returnValue VARCHAR(15) DEFAULT ''; IF(inArabic > 3999) THEN RETURN 'overflow'; END IF; IF(inArabic = 0) [...]]]></description>
			<content:encoded><![CDATA[<p>Convert an integer in the range 0 to 3999 to Roman numerals.</p>
<pre>CREATE FUNCTION `toRoman`(inArabic int unsigned) RETURNS varchar(15) CHARSET latin1 DETERMINISTIC
BEGIN
    DECLARE numeral CHAR(7) DEFAULT 'IVXLCDM';

    DECLARE stringInUse CHAR(3);
    DECLARE position tinyint DEFAULT 1;
    DECLARE currentDigit tinyint;

    DECLARE returnValue VARCHAR(15) DEFAULT '';

    IF(inArabic > 3999) THEN RETURN 'overflow'; END IF;
    IF(inArabic = 0) THEN RETURN 'N'; END IF;

    WHILE position <= CEIL(LOG10(inArabic + .1)) DO
        SET currentDigit := MOD(FLOOR(inArabic / POW(10, position - 1)), 10);

        SET returnValue := CONCAT(
            CASE currentDigit
                WHEN 4 THEN CONCAT(SUBSTRING(numeral, position * 2 - 1, 1), SUBSTRING(numeral, position * 2, 1))
                WHEN 9 THEN CONCAT(SUBSTRING(numeral, position * 2 - 1, 1), SUBSTRING(numeral, position * 2 + 1, 1))
                ELSE CONCAT(
                    REPEAT(SUBSTRING(numeral, position * 2, 1), currentDigit >= 5),
                    REPEAT(SUBSTRING(numeral, position * 2 - 1, 1), MOD(currentDigit, 5))
                )
            END,
            returnValue);

        SET position := position + 1;
    END WHILE;
    RETURN returnValue;
END</pre>
]]></content:encoded>
			<wfw:commentRss>http://thenoyes.com/littlenoise/?feed=rss2&#038;p=156</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SHOW CREATE TRIGGER 5.0</title>
		<link>http://thenoyes.com/littlenoise/?p=154</link>
		<comments>http://thenoyes.com/littlenoise/?p=154#comments</comments>
		<pubDate>Wed, 12 Oct 2011 16:17:39 +0000</pubDate>
		<dc:creator>snoyes</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://thenoyes.com/littlenoise/?p=154</guid>
		<description><![CDATA[SHOW CREATE TRIGGER for 5.0 - 5.1.20 CREATE FUNCTION SHOW_CREATE_TRIGGER(in_trigger varchar(255)) RETURNS text READS SQL DATA BEGIN DECLARE returnText text; SELECT CONCAT_WS( " ", "CREATE TRIGGER", TRIGGER_NAME, ACTION_TIMING, EVENT_MANIPULATION, "ON", EVENT_OBJECT_TABLE, "FOR EACH ROW", ACTION_STATEMENT) into returnText FROM information_schema.triggers; RETURN returnText; END]]></description>
			<content:encoded><![CDATA[<p>SHOW CREATE TRIGGER for 5.0 - 5.1.20</p>
<pre>CREATE FUNCTION SHOW_CREATE_TRIGGER(in_trigger varchar(255))
RETURNS text READS SQL DATA
BEGIN
    DECLARE returnText text;
    SELECT CONCAT_WS(
        " ",
        "CREATE TRIGGER",
        TRIGGER_NAME,
        ACTION_TIMING,
        EVENT_MANIPULATION,
        "ON",
        EVENT_OBJECT_TABLE,
        "FOR EACH ROW",
        ACTION_STATEMENT) into returnText
    FROM information_schema.triggers;
RETURN returnText;
END</pre>
]]></content:encoded>
			<wfw:commentRss>http://thenoyes.com/littlenoise/?feed=rss2&#038;p=154</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reverse Roman Numerals</title>
		<link>http://thenoyes.com/littlenoise/?p=152</link>
		<comments>http://thenoyes.com/littlenoise/?p=152#comments</comments>
		<pubDate>Wed, 12 Oct 2011 16:16:54 +0000</pubDate>
		<dc:creator>snoyes</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://thenoyes.com/littlenoise/?p=152</guid>
		<description><![CDATA[Translate from Roman Numerals back to decimal. Legal range is 0 to 3999 (that is, N to MMMCMXCIX) You can use IV or IIII for 4. You could even use a string of twenty I's for 20, but there's a string limit of 15, since that's the length of the biggest well-formed numeral below 3999. [...]]]></description>
			<content:encoded><![CDATA[<p>Translate from Roman Numerals back to decimal. Legal range is 0 to 3999 (that is, N to MMMCMXCIX) You can use IV or IIII for 4. You could even use a string of twenty I's for 20, but there's a string limit of 15, since that's the length of the biggest well-formed numeral below 3999.</p>
<pre>CREATE FUNCTION fromRoman (inRoman varchar(15)) RETURNS integer DETERMINISTIC
BEGIN

    DECLARE numeral CHAR(7) DEFAULT 'IVXLCDM';

    DECLARE digit TINYINT;
    DECLARE previous INT DEFAULT 0;
    DECLARE current INT;
    DECLARE sum INT DEFAULT 0;

    SET inRoman = UPPER(inRoman);

    WHILE LENGTH(inRoman) > 0 DO
        SET digit := LOCATE(RIGHT(inRoman, 1), numeral) - 1;
        SET current := POW(10, FLOOR(digit / 2)) * POW(5, MOD(digit, 2));
        SET sum := sum + POW(-1, current < previous) * current;
        SET previous := current;
        SET inRoman = LEFT(inRoman, LENGTH(inRoman) - 1);
    END WHILE;

    RETURN sum;
END</pre>
]]></content:encoded>
			<wfw:commentRss>http://thenoyes.com/littlenoise/?feed=rss2&#038;p=152</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extract range characters</title>
		<link>http://thenoyes.com/littlenoise/?p=150</link>
		<comments>http://thenoyes.com/littlenoise/?p=150#comments</comments>
		<pubDate>Wed, 12 Oct 2011 16:15:56 +0000</pubDate>
		<dc:creator>snoyes</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://thenoyes.com/littlenoise/?p=150</guid>
		<description><![CDATA[Given a source string and a two-character range string, extracts all characters from the source that fall within the range. Sort of a simple version of the [A-Z] syntax from regular expressions. Examples: extractRange('123-ABC-456', 'AZ') returns 'ABC' extractRange('123-ABC-456', '09') returns '123456' CREATE FUNCTION extractRange(inString TEXT, inRange char(2)) RETURNS TEXT DETERMINISTIC BEGIN DECLARE returnString TEXT DEFAULT [...]]]></description>
			<content:encoded><![CDATA[<p>Given a source string and a two-character range string, extracts all characters from the source that fall within the range. Sort of a simple version of the [A-Z] syntax from regular expressions. </p>
<p>Examples:<br />
extractRange('123-ABC-456', 'AZ') returns 'ABC'<br />
extractRange('123-ABC-456', '09') returns '123456'</p>
<pre>CREATE FUNCTION extractRange(inString TEXT, inRange char(2))
RETURNS TEXT
DETERMINISTIC
BEGIN
DECLARE returnString TEXT DEFAULT '';
DECLARE pointer INT DEFAULT 1;
WHILE pointer <= CHAR_LENGTH(inString) DO
    IF MID(inString, pointer, 1) BETWEEN LEFT(inRange, 1) AND RIGHT(inRange, 1) THEN
        SET returnString := CONCAT(returnString, MID(inString, pointer, 1));
    END IF;
    SET pointer := pointer + 1;
END WHILE;
return returnString;
END</pre>
]]></content:encoded>
			<wfw:commentRss>http://thenoyes.com/littlenoise/?feed=rss2&#038;p=150</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FIND_IN_WILD_SET and FIND_WILD_IN_SET</title>
		<link>http://thenoyes.com/littlenoise/?p=148</link>
		<comments>http://thenoyes.com/littlenoise/?p=148#comments</comments>
		<pubDate>Wed, 12 Oct 2011 16:14:33 +0000</pubDate>
		<dc:creator>snoyes</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://thenoyes.com/littlenoise/?p=148</guid>
		<description><![CDATA[Two functions that work just like FIND_IN_SET, but support the % wildcard. SELECT FIND_IN_WILD_SET('true', 'this,returns,%true%'); SELECT FIND_IN_WILD_SET('true', 'this,returns,%false%'); SELECT FIND_WILD_IN_SET('tr%e', 'this,returns,true'); SELECT FIND_WILD_IN_SET('tr%e', 'this,returns,false'); DROP FUNCTION IF EXISTS FIND_IN_WILD_SET; DROP FUNCTION IF EXISTS FIND_WILD_IN_SET; DELIMITER // CREATE FUNCTION FIND_IN_WILD_SET(theString varchar(65535), theSet varchar(65535)) RETURNS boolean DETERMINISTIC BEGIN DECLARE delimiterCount int; DECLARE pos int DEFAULT 0; DECLARE [...]]]></description>
			<content:encoded><![CDATA[<p>Two functions that work just like FIND_IN_SET, but support the % wildcard.<br />
SELECT FIND_IN_WILD_SET('true', 'this,returns,%true%');<br />
SELECT FIND_IN_WILD_SET('true', 'this,returns,%false%');<br />
SELECT FIND_WILD_IN_SET('tr%e', 'this,returns,true');<br />
SELECT FIND_WILD_IN_SET('tr%e', 'this,returns,false');</p>
<pre>DROP FUNCTION IF EXISTS FIND_IN_WILD_SET;
DROP FUNCTION IF EXISTS FIND_WILD_IN_SET;

DELIMITER //

CREATE FUNCTION FIND_IN_WILD_SET(theString varchar(65535), theSet varchar(65535))
RETURNS boolean
DETERMINISTIC
BEGIN

DECLARE delimiterCount int;
DECLARE pos int DEFAULT 0;
DECLARE setElement varchar(65535);
DECLARE returnValue boolean DEFAULT FALSE;

SET delimiterCount := CHARACTER_LENGTH(theSet) - CHARACTER_LENGTH(REPLACE(theSet, ',', ''));

WHILE (pos <= delimiterCount) DO
    BEGIN
        SET setElement := SUBSTRING_INDEX(SUBSTRING_INDEX(theSet, ',', pos+1), ',', -1);
        SET returnValue := returnValue OR (theString LIKE setElement);
        SET pos := pos + 1;

    END;
END WHILE;

RETURN returnValue;

END//

CREATE FUNCTION FIND_WILD_IN_SET(theString varchar(65535), theSet varchar(65535))
RETURNS boolean
DETERMINISTIC
BEGIN

DECLARE delimiterCount int;
DECLARE pos int DEFAULT 0;
DECLARE setElement varchar(65535);
DECLARE returnValue boolean DEFAULT FALSE;

SET delimiterCount := CHARACTER_LENGTH(theSet) - CHARACTER_LENGTH(REPLACE(theSet, ',', ''));

WHILE (pos <= delimiterCount) DO
    BEGIN
        SET setElement := SUBSTRING_INDEX(SUBSTRING_INDEX(theSet, ',', pos+1), ',', -1);
        SET returnValue := returnValue OR (setElement LIKE theString);
        SET pos := pos + 1;

    END;
END WHILE;

RETURN returnValue;

END//

DELIMITER ;</pre>
]]></content:encoded>
			<wfw:commentRss>http://thenoyes.com/littlenoise/?feed=rss2&#038;p=148</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

