Hi Peter!
2014-03-19 18:03 GMT-03:00 Peter Laursen <[email protected]>: > Obivously this is the best solution > SELECT LENGTH("banana") - LENGTH( REPLACE("banana","n","")); > (so no need or a Stored Function) > > .. however you may consider to replace LENGTH with CHAR_LENGTH, This is > important if you use UTF8 and if you have non-ASCII characters (what you > undoubtedly have as a Brazilian person (I guess you are?)). This example > with the Spanish "ñ" character illustrates: > Yes =D Brazil heeh, sorry my english, i change some words and wrote sometimes as i think in portuguese (are you going? => you are going? kk portuguese have a different grammar) No problem :) i'm using latin1 here at columns and server and client > > SET NAMES utf8; > SELECT LENGTH("bañaña") - LENGTH( REPLACE("bañaña","ñ","")); > -- returns "4" (4 *bytes* more exactly) - and this result is not what your > are after! > > -- whereas > SET NAMES utf8; > SELECT CHAR_LENGTH("bañaña") - CHAR_LENGTH( REPLACE("bañaña","ñ","")); > -- returns "2" (2 *characters* more exactly) - and this is what you want. > yeap :) i know how to use charsets, char_length is the right function with multibyte text, but no problem :) i considred a nice idea form adam instead of remove the character, add a new character length(replace('banana','n','n+'))-length('banana') if i replace 'asdfasdf' with 'asdfasdf+', i have only one new character :) that's nice > > > -- Peter > thanks! > > > On Wed, Mar 19, 2014 at 6:16 PM, Federico Razzoli > <[email protected]>wrote: > >> When a PHP function does something you cannot do in SQL, you could call >> PHP from your queries using the Gearman UDF. >> >> https://launchpad.net/gearman-mysql-udf >> >> In most cases this should be faster than a stored function. I hope that >> in the future this will change, but who knows... >> >> Regards, >> Federico >> >> >> -------------------------------------------- >> Mer 19/3/14, Roberto Spadim <[email protected]> ha scritto: >> >> Oggetto: Re: [Maria-discuss] help - i'm not finding one sql function >> A: "pslawek83" <[email protected]> >> Cc: "Maria Discuss" <[email protected]> >> Data: Mercoledì 19 marzo 2014, 16:18 >> >> wow! >> thanks kk i was trying to find a php like functionyour >> idea is very nice :) thank you! >> substr_count => >> (length(field)-length(replace(' >> ','',field))) >> >> /) >> >> 2014-03-19 12:16 GMT-03:00 >> pslawek83 <[email protected]>: >> >> Hi >> Roberto, >> You'll have to replace char >> => empty and get the difference in length. >> >> SELECT >> (length("banana") - replace("n", >> "", "banana")) >> >> >> There's probably no >> "standard" function to do that. >> >> >> Dnia 19 marca >> 2014 15:51 Roberto Spadim <[email protected]> >> napisał(a): >> >> >> >> >> >> >> hi guys, i'm not finding a function to >> return how many character i have, for example: >> >> "banana" >> >> i want a function that return 2 "n" >> characters, example: >> substr_count("banana","n") => >> 2 >> >> sorry it a begginners question, but i didn't found >> it in mysql/mariadb manual >> >> >> -- >> >> Roberto Spadim >> SPAEmpresarial >> Eng. Automação e Controle >> >> >> >> >> >> >> >> >> >> >> >> -- >> Roberto Spadim >> SPAEmpresarialEng. Automação e >> Controle >> >> -----Segue allegato----- >> >> _______________________________________________ >> Mailing list: https://launchpad.net/~maria-discuss >> Post to : [email protected] >> Unsubscribe : https://launchpad.net/~maria-discuss >> More help : https://help.launchpad.net/ListHelp >> >> >> _______________________________________________ >> Mailing list: https://launchpad.net/~maria-discuss >> Post to : [email protected] >> Unsubscribe : https://launchpad.net/~maria-discuss >> More help : https://help.launchpad.net/ListHelp >> > > > _______________________________________________ > Mailing list: https://launchpad.net/~maria-discuss > Post to : [email protected] > Unsubscribe : https://launchpad.net/~maria-discuss > More help : https://help.launchpad.net/ListHelp > > -- Roberto Spadim SPAEmpresarial Eng. Automação e Controle
_______________________________________________ Mailing list: https://launchpad.net/~maria-discuss Post to : [email protected] Unsubscribe : https://launchpad.net/~maria-discuss More help : https://help.launchpad.net/ListHelp

