Is is possible to update a column based on a REGEXP on another column?
am 21.01.2011 20:31:50 von Phil
--00032555145a701042049a604e7e
Content-Type: text/plain; charset=ISO-8859-1
I have a table which contains a username column which may be constructed
something like
somename[AAAAA] or [BBBBCCCCDDD]someothername
The AAAAA or BBBBCCCCDDD can be anything at all.
I've added a new column to the table to which I'd like to populate with the
value within the square brackets.
I could write something in perl or php to run through each and update them
but was wondering if there is a way to do this within mysql itself? The
regexp only returns a boolean so I can't see how to use that.
Regards
Phil
--
Distributed Computing stats
http://stats.free-dc.org
--00032555145a701042049a604e7e--
Re: Is is possible to update a column based on a REGEXP on another column?
am 22.01.2011 18:18:20 von Eric Bergen
There isn't a built in way but you can try http://www.mysqludf.org/lib_mysql=
udf_preg/
I would go with the php/perl script if this is a one time thing.
-Eric
On Jan 21, 2011, at 11:31 AM, Phil wrote:
> I have a table which contains a username column which may be constructed
> something like
>=20
> somename[AAAAA] or [BBBBCCCCDDD]someothername
>=20
> The AAAAA or BBBBCCCCDDD can be anything at all.
>=20
> I've added a new column to the table to which I'd like to populate with th=
e
> value within the square brackets.
>=20
> I could write something in perl or php to run through each and update them=
> but was wondering if there is a way to do this within mysql itself? The
> regexp only returns a boolean so I can't see how to use that.
>=20
> Regards
>=20
> Phil
>=20
>=20
> --=20
> Distributed Computing stats
> http://stats.free-dc.org
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg
Re: Is is possible to update a column based on a REGEXP on another column?
am 24.01.2011 12:29:15 von Johan De Meersman
--0015174c4312eef98a049a95e8a4
Content-Type: text/plain; charset=ISO-8859-1
If the bracketed stuff really can be anything, you're better off doing it
externally, I guess. If you can be reasonably sure that there'll not be any
square brackets in there, you can fluff about with instr() and substr().
On Sat, Jan 22, 2011 at 6:18 PM, Eric Bergen wrote:
> There isn't a built in way but you can try
> http://www.mysqludf.org/lib_mysqludf_preg/
>
> I would go with the php/perl script if this is a one time thing.
>
> -Eric
>
> On Jan 21, 2011, at 11:31 AM, Phil wrote:
>
> > I have a table which contains a username column which may be constructed
> > something like
> >
> > somename[AAAAA] or [BBBBCCCCDDD]someothername
> >
> > The AAAAA or BBBBCCCCDDD can be anything at all.
> >
> > I've added a new column to the table to which I'd like to populate with
> the
> > value within the square brackets.
> >
> > I could write something in perl or php to run through each and update
> them
> > but was wondering if there is a way to do this within mysql itself? The
> > regexp only returns a boolean so I can't see how to use that.
> >
> > Regards
> >
> > Phil
> >
> >
> > --
> > Distributed Computing stats
> > http://stats.free-dc.org
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=vegivamp@tuxera.be
>
>
--
Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel
--0015174c4312eef98a049a95e8a4--