2016-12-15 74 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