I know i can update multiple records at once using something like:

$sql = mysql_query("UPDATE table1 SET text_field='text' WHERE id_field=100");

Sure, it'll update multiple rows in one query ... but every row's specified field (text_field in my example) will be updated with the same information. Is there any way that I can update multiple rows/fields in a single query? For example, I might want want something similar to this:

UPDATE table1 SET text_field='text1' WHERE id_field=100;
UPDATE table1 SET text_field='text2' WHERE id_field=101;

But, in a single query ... much like the INSERT command:

INSERT INTO table1 (id_field, text_field) VALUES(100, 'text1'), (101, 'text2');

BTW, I want this because if I run seperate queries for each of the 30,000 rows that need to be updated, it takes forever to process. Thank you all.

    There is no SQL command that does what you describe. Try to figure out how to update as many records as possible by using relevant WHERE clauses.

    UPDATE mytable SET nextdaytocheck to 'monday' where nextdaytocheck='thursday'

    etc.

      Write a Reply...