bloginfo('name');

bloginfo('description');

SUBSTRING_COUNT() FOR MySQL

Januar 13th, 2009 by Blu:RayNe

Just as needed…

DROP FUNCTION IF EXISTS SUBSTRING_COUNT;
CREATE FUNCTION SUBSTRING_COUNT (haystack TEXT, needle VARCHAR(255)) RETURNS INT DETERMINISTIC
BEGIN
    RETURN LENGTH(haystack) – LENGTH(REPLACE(haystack, needle, ""));
END
Filed under Allgemein having 1 Comment »

One Response

  1. jan says:

    its not 100% correct. here’s a better one:


    RETURN (LENGTH(haystack) – LENGTH(REPLACE(haystack, needle, “”)))/LENGTH(needle);

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.