Input data into single mysql column on certain row
How 开发者_JS百科would i insert information into a column in a mysql table where in a specific row. For example, I want to insert the word politics into the column interests in a row where name is john.
mysql_query("UPDATE tableName SET interests='politics' WHERE name='john'");
If "politics" and "john" are php variables:
mysql_query("UPDATE tableName SET interests='".$interest."' WHERE name='".$name."'");
Further readings: PHP MySQL Update
UPDATE table SET interests='politics' WHERE name='john';
If you want to add a new profile then use INSERT INTO Profile (name,interests) VALUES ('john','politics'); If you want to add 'interests' to john's profile use UPDATE Profile SET interests='politics' WHERE name='john';
INSERT INTO table_name VALUES (v1,v2,v3,...);
or
INSERT INTO table_name (c1,c2,c3,...) VALUES (v1,v2,v3,...);
精彩评论