[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

MySQL copying a columns data

Hello Experts
I am using Mysql
I have a column A which contains about 2000 image names eg "myimage.jpg"
I have a Column B
I want to copy the images/ plus imagename  into colum B
So the finished entry in Column B wil read images/myimage.jpg
Can anyone please suggest a method to carry this out?

Many thanks

John
0
johnhardy
Asked:
johnhardy
  • 4
  • 2
  • 2
3 Solutions
 
Ray PaseurCommented:
Sure, run a query to SELECT the image name column A from the table.  With each row, UPDATE the image name column B with the literal string 'images/' plus thedata from the row of the SELECT query.  It should finish in about one or two seconds!
0
 
johanntagleCommented:
If I understand you correctly (you do mean the table has 2000 rows with an image name assigned to column_a for each row right?) you can do this in one UPDATE statement:

update table_name set column_b = concat('images/', column_a);
0
 
johnhardyAuthor Commented:
Thanks

I will come back a bit later.

Regards
John
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
johnhardyAuthor Commented:
Had a quick look before being off!

I imagine I perhaps need to use something like MySQL Workbench for this. I have not used the workbench before

Would it be possible to give me some directions how to achive this please. I am familiar with creating a query and a view but wanted to update the table if this is possible.

Thanks
John
0
 
johanntagleCommented:
I already gave you the statement you need to run to update the table above.  You can find the official documentation on MySQL workbench at http://dev.mysql.com/doc/workbench/en/.  There's a getting started tutorial chapter there.
0
 
Ray PaseurCommented:
Maybe we need to understand this, I have a column A which contains about 2000 image names...

Do you have one row with 2000 image names in a column or do you have 2000 rows with one image name in a column?
0
 
johnhardyAuthor Commented:
Sorry for not making myself clear Ray its 2000 imagenames eg  written as "myimage.jpg"

I always find mysql documentation daunting!
Thanks
John
0
 
johnhardyAuthor Commented:
Very many thanks for the help again

John
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now