MYSQL数据 [英] MYSQL data

查看:68
本文介绍了MYSQL数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个控制台应用程序,该应用程序必须根据mysql中的数据生成报告(根据电子邮件列编写报告).我想做的是,用一整列填充数据表.然后,程序应遍历数据表.并将所有电子邮件添加到我在mysql中创建的另一个表中.但是它必须验证它添加的电子邮件不在数据库中.因此,它应该在添加数据之前检查数据库.

请问有人可以帮忙吗?

预先谢谢您.

I am writing a console application which must generate reports according to the data in mysql(write the report according to the email column). What i want to do is, populate a datatable with the one entire column. Then, the program should loop through the datatable. And add every email it comes accross to another table i created in mysql. But it must verify that the email it is adding is not already in the database. So it should check the database before just adding data.

Could i ask anyone for help on this?

Thank you in advance.

推荐答案

您可以在插入记录之前尝试检查特定的记录电子邮件是否已经存在.

You can try before inserting a record for checking whether the specific record-email is already been there or not.

select cout(emailid) where emailid='xyz@abc.com'
or
select * where emailid='xyz@abc.com'



如果检索到的查询结果包含任何行,则您不得插入该电子邮件ID已经存在的记录.



if retrieved query result contains any row then you must not insert the record with that email id as its already present.


另一种方法是:
Another way is to:
SELECT DISTINCT email FROM tablename


这将返回表中电子邮件地址的唯一列表,并避免循环浏览结果.


This will return a unique list of the email addresses in the table and prevent having to loop through results.


这篇关于MYSQL数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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