我对这些代码行感到困惑和沮丧:
String updateSQL="UPDATE " + tableName + " set " + secondColumn + "='"+ value2 + "',"+ thirdColumn + "='"+ value3 +"'" + "," + fourthColumn +"='"+ value4 +"'" + "where " + firstColumn + " = "+ checkvalue ;
我让这个查询完美地工作!虽然我有另一个运行不完美但风格相同的查询:
String updateSQL="UPDATE " + tableName + " set " + secondColumn + "='"+ value2 +"'" + ","+ thirdColumn + "='"+ value3 +"'" + "," + fourthColumn +"='"+ value4 +"'" + "," + fifthColumn +"='"+ value5 +"'" + "where " + firstColumn + " = "+ checkvalue ;
在尝试更新时运行这行代码时,我收到错误消息“Where 子句中 'PNO3' 中的未知列”
虽然我知道我在第一列中有 PNO3,但在对第一个 Query 执行相同操作时,它会找到它吗?有什么帮助吗?
我使用此 switch 语句来确保列指向正确的列。
switch (tableName) {
case "s":
firstColumn = "ID";
secondColumn = "Namn";
thirdColumn = "Efternamn";
fourthColumn = "Adress";
break;
case "p":
firstColumn = "PNO";
secondColumn = "PNAME";
thirdColumn = "COLOR";
fourthColumn = "WEIGHT";
fifthColumn = "CITY";
break;
case "j":
firstColumn = "JNO";
secondColumn = "JNAME";
thirdColumn = "CITY";
break;
case "spj":
firstColumn = "SNO";
secondColumn = "PNO";
thirdColumn = "JNO";
fourthColumn = "QTY";
break;
}