SQL 删除语句怎么写呢?

我的SQL语句是这样写的:delete from studentInfo where stuid = 2
但是、所影响的行数为 0
数据库中的记录并没有少!
是哪里出了问题?

另外一个问题!
我的数据库删除操作的方法是这么写的:
/删除学员基本信息的操作
//方法的名称叫做deleteManagerStudentInformation()
public boolean deleteManagerStudentInformation(ArrayList arraylist)
{
//获得数据操作对象
try {
Statement stmt = con.createStatement() ;

//遍历ARRAYLIST中的JAVABEAN进行数据库的删除操作
for(int i=0; i<arraylist.size(); i++)
{
StudentInformationBean studentBean = new StudentInformationBean() ;
stmt.executeUpdate("delete from [studentInfo] where stuid = "+studentBean.getStuID() ) ;
}
return true;
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("删除学员基本信息的方法出错、方法名称叫做 deleteManagerStudentInformation()") ;
e.printStackTrace();
return false ;
}

}
程序运行起来、并没有报错!
可是、数据库中的数据记录没有少!
我这样的在同一个方法中、能多次用STATEMENT.EXECUTEUPDATE();
多次操作数据吗?

小弟、谢谢各位了!

其实我觉得你应该写成
delete from studentInfo where stuid = ‘2’试试,像你说的如果不是ID字段类型不是int,应该是不会出现这种情况的,你试试,不行再想别的办法
当然下面的语句也打上引号试试:
stmt.executeUpdate("delete from studentInfo where stuid = '"+studentBean.getStuID()+"'" ) ;
试试吧,祝你好运!
温馨提示:答案为网友推荐,仅供参考
第1个回答  2020-01-09
delete
语句
delete
语句用于删除表中的行。
语法
delete
from
表名称
where
列名称
=

删除某行
delete
from
表名称
where
列名称
=
值(删除条件)
删除所有行
可以在不删除表的情况下删除所有的行。这意味着表的结构、属性和索引都是完整的:
delete
from
表名
或者:
delete
*
from
表名
通过使用
drop
语句,可以轻松地删除索引、表和数据库
drop
index
索引名称
drop
table
表名称
drop
database
数据库名称
不删除表,只删除表中的数据
truncate
table
表名称
第2个回答  2009-03-19
stmt.executeUpdate("delete from [studentInfo] where stuid = '"+studentBean.getStuID()+"'" ) ;
第3个回答  2009-03-19
delete from studentInfo where trim(stuid)=2
delete from studentInfo where trim(stuid)='2'
你都试试
第4个回答  2009-03-19
你写的那条是因为2没有打引号。
这个方法中studentBean.getStuID() 的值是什么啊?里面没东西啊 。
相似回答