Solved

MySQL copying a columns data

Posted on 2013-01-06
8
364 Views
Last Modified: 2013-01-12
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
Comment
Question by:johnhardy
  • 4
  • 2
  • 2
8 Comments
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 38749116
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
 
LVL 24

Accepted Solution

by:
johanntagle earned 250 total points
ID: 38749436
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
 

Author Comment

by:johnhardy
ID: 38749996
Thanks

I will come back a bit later.

Regards
John
0
 

Author Comment

by:johnhardy
ID: 38750054
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
Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 24

Expert Comment

by:johanntagle
ID: 38750152
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
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 38750559
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
 

Assisted Solution

by:johnhardy
johnhardy earned 0 total points
ID: 38750944
Sorry for not making myself clear Ray its 2000 imagenames eg  written as "myimage.jpg"

I always find mysql documentation daunting!
Thanks
John
0
 

Author Closing Comment

by:johnhardy
ID: 38769725
Very many thanks for the help again

John
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now