Access to update table

I have a table in which I want to update multiple rows. These lines are as follows:

Cars/Audi/Norway/model1/sports.Jpeg
Cars/Audi/Norway/model1/classic.Jpeg
Cars/Audi/Norway/model1/v8.Jpeg
Cars/Audi/Norway/model1/v6.Jpeg

Now I only want to update model1, say, I want to make the second model. so how can i do this in only one request? I am using this query:

string path="some string";
string name = "some string";

("select replace(filepath,'" + path + "','" + name + "')

so that it looks like

    Cars/Audi/Norway/model10/sports.Jpeg
    Cars/Audi/Norway/model10/classic.Jpeg
    Cars/Audi/Norway/model10/v8.Jpeg
    Cars/Audi/Norway/model10/v6.Jpeg

any idea?

0
source share
2 answers
UPDATE CarImages
SET Path=Replace(Path,'/Model1/','/Model10/');

Assuming the table is called "CarImages" and the field you want to update is called Path.

+2
source

replace is only available when working inside Access itself; it is a VBA function, not Jet / ACE. You will need something like:

SELECT Left([field1],InStr([field1],"/model1")-1) 
    & "/model2" 
    & Mid([field1],InStr([field1],"/model1")+Len("/model1")) AS result
FROM Table1;
0
source

All Articles