safi
safi

Reputation: 3766

update table access

I have a table in which i want to update a multiple rows. the row data is like this:

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 want only to update the model1, let say i want to make it model two. so how can i do it in just one query? i am using this query:

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

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

so it seem 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?

Upvotes: 0

Views: 226

Answers (2)

Fionnuala
Fionnuala

Reputation: 91376

replace is only available when working within 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;

Upvotes: 0

Duncanmhor
Duncanmhor

Reputation: 43

UPDATE CarImages
SET Path=Replace(Path,'/Model1/','/Model10/');

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

Upvotes: 2

Related Questions