Richard:
That is real good. Thank you very much.
You are using a character count, so I extrapolated a little further and
this query below then could ostensibly provide the [<TAG>] insert after
the second sentence ending with a period by searching for the second
occurrence of the textual matter ". " [period space]:
UPDATE
table_name
SET
column_to_update =
CONCAT(
SUBSTRING_INDEX('column_to_update', '. ',
2),'[<TAG>]',SUBSTR(column_to_update,
LENGTH(SUBSTRING_INDEX('column_to_update', '. ', 2))+1)
);
Warmest regards,
Peter Sawczynec
Technology Dir.
blūstudio
941.893.0396
[email protected]
www.blu-studio.com
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Richard Safran
Sent: Wednesday, August 26, 2009 6:59 AM
To: MySQL SIG
Subject: Re: [mysql] Query Assist
Peter,
Something like this in PHP:
$sql = 'UPDATE table_name SET column_to_update =
CONCAT(SUBSTR(column_to_update,1,133),'.mysql_escape_string($text_to_ins
ert).',SUBSTR(column_to_update,134))';
Richard Safran
Peter Sawczynec wrote:
> I want to write an update query for MySQL 5.x that will update an
entire
> table. The query will have to insert a text term tag (such as [<TAG>]
)
> into a field.
>
>
>
> The field column to be updated will be a text type and likely contain
> several hundred words comprised of sentences and paragraphs.
>
>
>
> The text term needs to be inserted after the 133 word or at the end of
> the textual content if shorter.
>
>
>
> Can SQL do this on its own?
>
>
>
> If you happen to have an example laying around because you did
something
> just like this once, thanks, gracias, merci, dank, grazi.
>
>
>
> Warmest regards,
>
>
>
> Peter Sawczynec
>
> Technology Dir.
>
> blūstudio
>
> 941.893.0396
>
> [email protected] <mailto:[email protected]>
>
> www.blu-studio.com
>
>
>
>
>
>
>
------------------------------------------------------------------------
>
> _______________________________________________
> New York PHP Community MySQL SIG
> http://lists.nyphp.org/mailman/listinfo/mysql
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
_______________________________________________
New York PHP Community MySQL SIG
http://lists.nyphp.org/mailman/listinfo/mysql
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
_______________________________________________
New York PHP Community MySQL SIG
http://lists.nyphp.org/mailman/listinfo/mysql
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php