mysql删除查询,MySql多表删除查询

I am trying to execute a multi table delete in on sql query but I cant seem to get it right. the query is below. any help will be deeply appreciated. The ''id'' is already set from a different portion of the code.connection = Properties.Settings.Default.cvmanagerConnectionString;

sql = "delete from apps, contacts, dept using apps join contacts, join dept where apps.FileLoc = contacts.FileLoc AND apps.FileLoc = dept.FileLoc AND apps.FileLoc = ''" + id + "''";

try

{

SqlConnection conn = new SqlConnection(connection);

SqlCommand cmd = new SqlCommand(sql, conn);

conn.Open();

cmd.ExecuteNonQuery();

}

catch (Exception ex)

{

MessageBox.Show(ex.ToString());

}

解决方案Judging from the examples here, it looks like you have an extra '','' in your query. I think it should be using apps join contacts join dept where

private void button1_Click(object sender, EventArgs e)

{

SqlConnection con = new SqlConnection("Data Source=jcs-pc;Initial Catalog=deepak;Persist Security Info=True;User ID=sa;Password=jcs#");

SqlCommand cmd = new SqlCommand();

string s1 = "insert into deep (id,name)values(1,''sandeep'')";

string s2 = "insert into deep (id,name)values(1,''sandeep'')";

string s3 = "insert into sany (id,name'')values(1,''sandeep'')";

cmd.CommandText = s1 + s2 + s3;

cmd.Connection = con;

con.Open();

cmd.ExecuteNonQuery();

con.Close();

}

(sandeep.k115@gmail.com)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值