Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Update only certain fields in a table

Tags:

forms

php

mysql

I have some insurance information in a website, and I'd like to only edit certain fields the user wants to change like for example: user, id, phone, address, city

and the user wants to change his city and phone...do i have to make a query for each specific case or is there a code that can help me retrieve the key(phone) and value (9397171602)??

to then send it in a query

like image 222
Skynight Avatar asked Feb 23 '23 19:02

Skynight


1 Answers

Basic update would take the form of:

UPDATE table_name SET column_1 = value_1, column_2 = value_2 WHERE column_3 = value_3

Where col1, col2 would be your city and phone, and col3 would be the user id. Check out the MySQL website http://dev.mysql.com/doc/refman/5.0/en/update.html for more info

like image 196
neurotik Avatar answered Feb 25 '23 12:02

neurotik