JAVA SQL insert 语句写法
Stringsql="insertintostucou(stuno,stuname,class,chinese,math,english)values('"+studen...
String sql = "insert into stucou(stuno,stuname,class,chinese,math,english)
values('"+studentNum.getText()+"','"+studName.getText()+"','"+studClass.getText()+"',"+Integer.parseInt(studMath.getText())+",
"+Integer.parseInt(studJava.getText())+","+Integer.parseInt(studEnglich.getText())+")";
哪位大虾 能够看看这个句子有什么问题,谢谢了。 展开
values('"+studentNum.getText()+"','"+studName.getText()+"','"+studClass.getText()+"',"+Integer.parseInt(studMath.getText())+",
"+Integer.parseInt(studJava.getText())+","+Integer.parseInt(studEnglich.getText())+")";
哪位大虾 能够看看这个句子有什么问题,谢谢了。 展开
3个回答
展开全部
SQL INSERT INTO 语句用于向表格中插入新的行。
语法
INSERT INTO 表名称 VALUES (值1, 值2,....)
也可以指定所要插入数据的列:
INSERT INTO table_name (列1, 列2,...) VALUES (值1, 值2,....)
"Persons" 表:
LastName FirstName Address City
Carter Thomas Changan Street Beijing
SQL 语句:
INSERT INTO Persons VALUES ('Gates', 'Bill', 'Xuanwumen 10', 'Beijing')
结果:
LastName FirstName Address City
Carter Thomas Changan Street Beijing
Gates Bill Xuanwumen 10 Beijing
在指定的列中插入数据
"Persons" 表:
LastName FirstName Address City
Carter Thomas Changan Street Beijing
Gates Bill Xuanwumen 10 Beijing
SQL 语句:
INSERT INTO Persons (LastName, Address) VALUES ('Wilson', 'Champs-Elysees')
结果:
LastName FirstName Address City
Carter Thomas Changan Street Beijing
Gates Bill Xuanwumen 10 Beijing
Wilson Champs-Elysees
语法
INSERT INTO 表名称 VALUES (值1, 值2,....)
也可以指定所要插入数据的列:
INSERT INTO table_name (列1, 列2,...) VALUES (值1, 值2,....)
"Persons" 表:
LastName FirstName Address City
Carter Thomas Changan Street Beijing
SQL 语句:
INSERT INTO Persons VALUES ('Gates', 'Bill', 'Xuanwumen 10', 'Beijing')
结果:
LastName FirstName Address City
Carter Thomas Changan Street Beijing
Gates Bill Xuanwumen 10 Beijing
在指定的列中插入数据
"Persons" 表:
LastName FirstName Address City
Carter Thomas Changan Street Beijing
Gates Bill Xuanwumen 10 Beijing
SQL 语句:
INSERT INTO Persons (LastName, Address) VALUES ('Wilson', 'Champs-Elysees')
结果:
LastName FirstName Address City
Carter Thomas Changan Street Beijing
Gates Bill Xuanwumen 10 Beijing
Wilson Champs-Elysees
展开全部
插入数据时 表中提供的字段数量和类型 要和插入的一致
现在提供6个字段 但是准备插入7个数据 不允许
现在提供6个字段 但是准备插入7个数据 不允许
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
写成这样就可以了
String sql =
"insert into stucou(stuno,stuname,class,chinese,math,english)"+
"values('"+studentNum.getText()+"','"+studName.getText()+"','"+studClass.getText()
+"',"+Integer.parseInt(studMath.getText())+","
+Integer.parseInt(studJava.getText())+","+Integer.parseInt(studEnglich.getText())+")";
String sql =
"insert into stucou(stuno,stuname,class,chinese,math,english)"+
"values('"+studentNum.getText()+"','"+studName.getText()+"','"+studClass.getText()
+"',"+Integer.parseInt(studMath.getText())+","
+Integer.parseInt(studJava.getText())+","+Integer.parseInt(studEnglich.getText())+")";
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |