CREATE FUNCTION `getCount`(`myStr` VARCHAR(4096), `myword` VARCHAR(100)) RETURNS int(11) READS SQL DATA DETERMINISTIC RETURN ROUND ( ( LENGTH(myStr) - LENGTH( REPLACE ( myStr, myword, "") ) ) / LENGTH(myword) )
Usage :
Select getCount('Moshe Test My Code','M') #Returns : 2
No comments:
Post a Comment