从ID的C#列表中删除mysql服务器中的行 [英] Delete rows from mysql server from a list of ID's C#

查看:319
本文介绍了从ID的C#列表中删除mysql服务器中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从C#中的ID列表中删除MySQL表中的一系列行.表格中有一个employeeID行.基本上我的问题是我将使用哪种语法?

I'm trying to delete a series of rows in a MySQL table from a list of ID's in C#. There's an employeeID row in the table. Basically my question is what kind of syntax would I use?

推荐答案

您可能会在DELETE中使用IN子句:

You would probably use an IN clause in your DELETE:

DELETE FROM `EmployeeTable` WHERE EmployeeID IN (2, 3, 4, 5, ...)

这可以通过String.Join方法来实现以生成列表:

This could be implemented with the String.Join method to generate the list:

var query = "DELETE FROM `EmployeeTable` WHERE EmployeeID IN (" +
    String.Join(",", myArray) + ")";

这篇关于从ID的C#列表中删除mysql服务器中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆