Hi,

I'm just want to ask if it's possible if I want to update multiple record with same condition at the same time.

For example, I have a table named userTable, it has two field, year and status fields.
On year field, it has value of years and on status field has default value New.

I'am using asp to perform this operation :

var status = "Expired";
var year = "2012";

var sql  = "UPDATE userTable ";
    sql += "SET ";
    sql += "status = '"+status+"'";
    sql += "WHERE ";
    sql += "year = " +year;

On year field, it has multiple record that has value 2012. So, what i'm trying to do is to update record on status field which the year is equal to 2012.

It can run smoothly if only one record has year value equal to 2012, but not if has multiple record with same value.

I'm already try to run this code but got error. So, anyone can help me solve this problem.
Thank You.

UPDATE alters all records to which the condition applies. It does not matter if it applies only to one, to several, to none or to all records.
For multiple conditions add them to the WHERE clause with the boolean operators AND, NOT and OR, like in

UPDATE userTable SET status = 'New' WHERE year = 2000 OR year = 2001;

It can run smoothly if only one record has year value equal to 2012, but not if has multiple record with same value.

I don't see why this code will not work.
By the way what is the error you are getting ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.