I'm new to MySQL and I want to update an entire row in MySQL with a new array, so far all the examples of the Update query involves specifying the column name and a new value for that column, like this:
"UPDATE tablename SET columnname = '".$new_value."' WHERE columnname = '".$value."'";
How can I update an entire record with the update query or should I use the replace query?
Any advice will be appreciated.
Edit: Is there a query which doesn't require to specify all the column names and new column values?
Basically I want to have a query that looks something like this:
Update entirerow with thisarray where primarykeycolumn='thisvalue'
That is the correct way.
UPDATE TABLENAME SET COLUMNAME = VALUE, COLUMN2NAME = VALUE, ETC WHERE CONDITION
To do that you need to
So the final query would look like
UPDATE tablename
SET col1 = 'val1', col2 = 'val2' ...
WHERE id = id_value
There is no any magic command for updating the "whole row" in sql other than I shown above. And REPLACE
is definitely not what you need here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With