Is there a way ?

Is there a way ?

am 16.08.2009 18:14:09 von m i l e s

Hi,

I'm a little rusty in my SQL statements, and I'm not all that certain
that this can be done.

IF I have a field with the contents like:

"http://beta.somedomain.com/url/url/url=2"

where 2 is the record ID value. And I need to change the contents of
that field to read:

"http://www.somedomain.com/url/url/url=2"

How would I accomplish this with a native SQL statement ?

I was thinking that I'd just export the contents of the table, and do
a text manipulation against the field, only to realize that the record
id value is embedded in the link of the field. Which means that I
can't change the record id value at all. Or turn off the auto
increment of the keyfield because it will invalidate the records when
its turned back on....

Any suggestions as to how I might clean this up ????

Thanks.

Miles

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: Is there a way ?

am 17.08.2009 03:13:09 von Johnny Withers

--0016e6d96d90e2279a04714c1a7f
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

UPDATE table SET col1=REPLACE(col1,'beta.','www.');

Would do what you would need.

On Sun, Aug 16, 2009 at 11:14 AM, m i l e s wrote:

> Hi,
>
> I'm a little rusty in my SQL statements, and I'm not all that certain that
> this can be done.
>
> IF I have a field with the contents like:
>
> "http://beta.somedomain.com/url/url/url=2"
>
> where 2 is the record ID value. And I need to change the contents of that
> field to read:
>
> "http://www.somedomain.com/url/url/url=2"
>
> How would I accomplish this with a native SQL statement ?
>
> I was thinking that I'd just export the contents of the table, and do a
> text manipulation against the field, only to realize that the record id
> value is embedded in the link of the field. Which means that I can't change
> the record id value at all. Or turn off the auto increment of the keyfield
> because it will invalidate the records when its turned back on....
>
> Any suggestions as to how I might clean this up ????
>
> Thanks.
>
> Miles
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=johnny@pixelated.net
>
>


--
-----------------------------
Johnny Withers
601.209.4985
johnny@pixelated.net

--0016e6d96d90e2279a04714c1a7f--

Re: Is there a way ?

am 17.08.2009 10:11:41 von Martijn Tonies

Hello Miles,

> I'm a little rusty in my SQL statements, and I'm not all that certain
> that this can be done.
>
> IF I have a field with the contents like:
>
> "http://beta.somedomain.com/url/url/url=2"
>
> where 2 is the record ID value. And I need to change the contents of

That is rather "unfortunate" ... better change the design while you still
can. Just add a column with a unique ID.

In general, EVERY tables should have a primary key in order to identify
each record.

> that field to read:
>
> "http://www.somedomain.com/url/url/url=2"
>
> How would I accomplish this with a native SQL statement ?
>
> I was thinking that I'd just export the contents of the table, and do
> a text manipulation against the field, only to realize that the record
> id value is embedded in the link of the field. Which means that I
> can't change the record id value at all. Or turn off the auto
> increment of the keyfield because it will invalidate the records when
> its turned back on....
>
> Any suggestions as to how I might clean this up ????

See above, add a column, create a unique ID for it.

With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

Database questions? Check the forum:
http://www.databasedevelopmentforum.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org