Inserting text to multiple rows

[expired user #6090]'s profile image [expired user #6090] posted 12 years ago in General Permalink
Hi there, I'm pretty much a novice to MySQL but lately I've managed to covert a music database from access to mysql with the help of this software, but I've come across a problem.

I have a column of over 10,000 rows containing the file name of each MP3, "filename.MP3" for example. My problem is I need to insert the path location of the MP3 before the file name, like so "c:\database\audio\filename.MP3"

Is there any kind of query code that I can use to insert this into every row ?

Thanks
ansgar's profile image ansgar posted 12 years ago Permalink
You should not store redundant information in a database. Rather do that per application logic.

However, you can do that with an UPDATE query:
UPDATE table SET filename=CONCAT('c:\\database\\audio\\', filename)

Note the double slashes - backslashes must be escaped using backslash.
[expired user #6090]'s profile image [expired user #6090] posted 12 years ago Permalink
That makes no sense to me, can you please explain more
ansgar's profile image ansgar posted 12 years ago Permalink
Hm, this is simple SQL - if that does not make sense you should probably not use HeidiSQL. However, you can enter such a UPDATE... query into a "Query" tab and hit F9 to execute that.
[expired user #6090]'s profile image [expired user #6090] posted 12 years ago Permalink
sorry my mistake I didn't realise the "filename" in the query had to be changed to the column name, all sorted now, thanks for your help

Please login to leave a reply, or register at first.