c# 数据库添加的where语句

来源:百度知道 编辑:UC知道 时间:2024/05/16 12:22:23
我用的是vs2005 c#

String strSQL = "insert into question (q_answer) "
+ "values('" + TextBox1.Text + "') "
如果想加where 格式是什么

给个完整的语句,谢谢
我是想在原有的记录中的一个字段上添加信息 当然要判断添加到哪个字段 我的主键是q_id

你是想判断是否已经存在吗?
"if not exists(select * from question where q_answer = '"TextBox1.Text+"') insert into question (q_answer) values('" + TextBox1.Text + "') "
是在已有的字段上添加信息?那用update语句啊
String strSQL = "update [question] set [q_answer] = '"+TextBox1.Text+"' where [q_id]='"+q_id+"'";

你这条语句不能使用Where 条件。。但是可以
insert into question(q_answer) select answer from A
把A表的数据添加到question表中去。。。有多少添加多少

只有删除 更改 才可以加where条件:
Update A set username='张三' where userid=123

Delete A Where username like '张'%

添加是不需要where语句的
如果你添加是需要条件的 你就在添加之前进行判断或者处理 在进行添加 insert语句是跟不了where的 over

对哦~ 这个是insert,就是插入一条原本没有的记录,where是查询已经存在的记录的

插入 新的一行 不需要条件。

这个不能用where