clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1130697 fiddles created (16595 in the last week).

CREATE FUNCTION GetStringCount(strValue TEXT, strCount TEXT) RETURNS INTEGER LANGUAGE SQL AS ' SELECT COALESCE((CHAR_LENGTH(strValue) - CHAR_LENGTH(REPLACE(strValue, strCount, ''''))) / CHAR_LENGTH(strCount), 0); ';
 hidden batch(es)


CREATE TABLE example ( col VARCHAR(4000) ); INSERT INTO example VALUES ('Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.'), ('At vero eos et accusam et justo duo dolores et ea rebum.'), ('Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.'), (NULL);
4 rows affected
 hidden batch(es)


SELECT GetStringCount('Hello', 'l'); SELECT GetStringCount('This costs 5$.', '$'); SELECT GetStringCount('This costs 5€.', '€');
getstringcount
2
getstringcount
1
getstringcount
1
 hidden batch(es)


SELECT *, GetStringCount(col, 'a') FROM example;
col getstringcount
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 11
At vero eos et accusam et justo duo dolores et ea rebum. 3
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 8
0
 hidden batch(es)