Solved

MySQL copying a columns data

Posted on 2013-01-06
8
399 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 110

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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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
 
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 110

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
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 look for a specific file type in a local or remote server directory using PHP.

738 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