开发者

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,...);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜