Skip to content Skip to sidebar Skip to footer

I'd Like To Have Characters Only (no Signs, Numbers And Spaces At All)

It should be done with SQLite just like this; yes, I know, it is quite easy task, If I use UDF(User Define Function). but, I have severe difficulty with it. so, looking for anothe

Solution 1:

I believe that you could base the resolution on :-

WITHRECURSIVE eachchar(counter,rowid,c,rest) AS (
        SELECT1,rowid,'',mycolumn AS rest FROM mytable
        UNIONALLSELECT counter+1,rowid,substr(rest,1,1),substr(rest,2) FROM eachchar WHERE length(rest) >0 LIMIT 100
    )
SELECT group_concat(c,'') AS mycolumn, myothercolumn, mycolumn AS original
FROM eachchar JOIN mytable ON eachchar.rowid = mytable.rowid 
WHERE length(c) >0AND (
        unicode(c) BETWEEN unicode('a') AND unicode('z') 
        OR unicode(c) BETWEEN unicode('A') AND unicode('Z')
    )
GROUPBY rowid;

Demo :-

Perhaps consider the following :-

/* Create the Test Environment */DROPTABLE IF EXISTS mytable;
CREATETABLE IF NOTEXISTS mytable (mycolumn TEXT, myothercolumn);
/* Add the Testing data */INSERTINTO mytable VALUES
    ('123-abc_"D E F()[]{}~`!@#$%^&*-+=|\?><<:;''','A')
    ,('123-xyz_"X Y Z()[]{}~`!@#$%^&*-+=|\?><<:;''','B')
    ,('123-abc_"A B C()[]{}~`!@#$%^&*-+=|\?><<:;''','C')
;

/* split each character thenconcatenat only the required characters*/WITHRECURSIVE eachchar(counter,rowid,c,rest) AS (
        SELECT1,rowid,'',mycolumn AS rest FROM mytable
        UNIONALLSELECT counter+1,rowid,substr(rest,1,1),substr(rest,2) FROM eachchar WHERE length(rest) >0 LIMIT 100
    )
SELECT group_concat(c,'') AS mycolumn, myothercolumn, mycolumn AS original
FROM eachchar JOIN mytable ON eachchar.rowid = mytable.rowid 
WHERE length(c) >0AND (
        unicode(c) BETWEEN unicode('a') AND unicode('z') 
        OR unicode(c) BETWEEN unicode('A') AND unicode('Z')
    )
GROUPBY rowid;
/* Cleanup Test Environment */DROPTABLE IF EXISTS mytable;

This results in :-

enter image description here

Post a Comment for "I'd Like To Have Characters Only (no Signs, Numbers And Spaces At All)"