I want to do something like
UPDATE * SET fieldName = "value" WHERE fieldName = "oldValue"
on an entire database - but that doesnt work - how hard should it be? Anyone know what the correct way to do this is?
I want to do something like
UPDATE * SET fieldName = "value" WHERE fieldName = "oldValue"
on an entire database - but that doesnt work - how hard should it be? Anyone know what the correct way to do this is?
I might be wrong, but I think an UPDATE statement can only modify data of a single table. It’s quite possible that you can achieve the same effect by literally specifying each table and doing joins, but that seems slightly redundant. I think your only choices are either two update statements or writing a stored procedure.
■■■■, thats kind of a problem…can anyone else verify there is no way to UPDATE an undetermined amount of tables that may or may not have a column with the right value?
The only other thing I can think is multiple queries - first one a SHOW TABLES that gets the field names and finds any with the relevant field, then for each table that has that field, it does the update…but if theres an easier way?
Yes, stored procedures.
Is that what a stored procedure is?
a stored procedure is a sql statement that is saved to your server and can be run by scheduling multiple tables/databases
http://dev.mysql.com/doc/refman/5.0/en/stored-procedures.html
:: Copyright KIRUPA 2024 //--