troubleshooting Question

I need to do a one time run query to grab values in a field and place the value into a new field in the same record.

Avatar of morako
morakoFlag for United States of America asked on
PHPMySQL ServerSQL
8 Comments1 Solution587 ViewsLast Modified:
This is a one time update to place the connection_id values from the log_body field into its own field connection_id.

Screenshot of table
I created the field connection_id in a table to better manipulate the data.  I need to grab the value after connection_id from a string in a field called Log_body and place the value into the connection_id field  currently NULL.  (View image)

select a value from data in a database field and update the same record with that value into a field.

<a href="index.php?t=network&amp;connection_id=4">ANOTHONY</a> added a <a href="index.php?wp=blog&amp;blog_id=2#comment_id2">blog comment</a>.

The data in the string above is in a database field called "log_body "  and I need to grab the connection_id value (in this field it would be 4) and update the same record with the connection_id in the field called connection_id.

Any thoughts on if this is possible.  How do I grab the value 4 .  Grab the value after connection_id=VALUE and before the " or &

<a href="index.php?t=network&amp;connection_id=4">
<a href="index.php?t=network&amp;connection_id=4&record=23">

Select ((Value after connection_id= "value" in the field)) `log_body` AND log_id

Then

$logidvar = $row['log_id'];         //place the log_id in a var to update same record

place value collected after connection_id= in the log_body string into a $variable

and

update `logs_table` set (connection_id  = ($variable) WHERE log_id = $logidvar

This is a one time update to place the connection_id values from the log_body field into its own field connection_id.

And I need to run the query once to update the current data (all records) so it needs to run recursively..
ASKER CERTIFIED SOLUTION
Scott Madeira

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros