从另一个数据表中删除数据表

编程入门 行业动态 更新时间:2024-10-25 10:26:08
本文介绍了从另一个数据表中删除数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我的应用程序中有一个主数据表,从该数据表中我使用DataView和RowFilter创建了另一个数据表.现在我需要从我的主表中删除该数据,该数据将由新创建的表保存. 谢谢..

Hi all, I have a main DataTable in my Application, From that DataTable i have created a another DataTable using DataView and RowFilter.Now I need to delete that data from My Main Table which data will hold by newly created Table. Thanks..

推荐答案

我有一个解决您问题的想法 您的表中有ID,名称,地址,phno等列... 然后将这些表数据过滤到一些表中. 然后,您可以在过滤后循环该dataview控件.并收集存在于过滤后的数据表中的ID. 然后编写sql命令以删除该数组中存在的所有行 Hi, I have an idea to solve your problem your table has columns like id,name,addr,phno... And you filtered these table data into some table right. And you can loop that dataview control after filtering .And collect that ids present in filtered data table. Then write sql command to delete all rows which are present in that array string strrono=""; for(int i=0;i<dataview.items.count;i++)> { if(strrno.Length>0) { strrno+=","+dataview.rows[i][0].tosting(); } else { strrno+=dataview.rows[i][0].tosting(); } } string query="delete from tablename where id in("+strrno+")";

我希望你有一个想法怎么做 我所有的最佳

I hope you got an idea how to do that All the Best

我建​​议使用多表删除语法,并加入存档表以进行删除.这样,您只删除两个表中的行. 简单示例: I recommend using the multi-table delete syntax, and joining to the archive table for your delete. That way you only delete rows that are in both tables. Simple Example: insert into archive select * from data; delete data.* from data inner join archive on archive.id = data.id;

除此之外,您可能需要考虑将其分解成较小的块以获得更好的性能.例如:

Beyond that, you may want to consider breaking this down into smaller chunks for better performance. For example:

insert into archive select * from data where id > 1000 and id <= 2000; delete data.* from data inner join archive on archive.id = data.id where data.id > 1000 and data.id <= 2000;

从手册中:dev.mysql/doc/refman/5.1/en/delete.html

From the manual: dev.mysql/doc/refman/5.1/en/delete.html

更多推荐

从另一个数据表中删除数据表

本文发布于:2023-10-16 10:36:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1497322.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!