2016-12-15 76 views
2

所以我有一个MySQL数据库,我想写一个IP地址到特定的和现有的行。如何将数据插入到特定行MySQL C#

例如,用户名“Johnny”登录,系统将进入用户名“Johnny”的行并写入列ipaddress

目前我只知道如何使用,以创建一个完整的新行:

queryStr = "INSERT INTO webappdemo.userregistration(firstname,middlename,lastname,email,phonenumber,username,slowHashSalt)" + 
      "VALUES(?firstname, ?middlename, ?lastname, ?email, ?phonenumber, ?uname, ?slowHashSalt)"; 

所以,问题是如何通过用户名和滤波写入特定列写现有行。

谢谢。

+0

看看这个帖子:[插入值与where子句(http://stackoverflow.com/a/9166197/3060520) –

+0

使用where子句更新查询。 – Shan

回答

1

希望你熟悉SQL UPDATE查询,寻找一个UPDATE语句。哪些可用于修改表中的现有行,所以在这里您必须使用UPDATE语句;我再补充一个样品,以及,你的代码看起来是这样的:

string querySql = "UPDATE webappdemo.userregistration SET" + 
        " [email protected] Where [email protected]"; 
// Add necessary parameters and execute the query 
// It will update that particular row