Solved

MySQL copying a columns data

Posted on 2013-01-06
8
376 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

914 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

14 Experts available now in Live!

Get 1:1 Help Now