如何避免重复插入数据? [英] how to avoid the duplication insert data?

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

问题描述

我正在做电子商务项目。我在产品表中插入了PID,产品名称。但在产品表中多次插入相同的产品名称。如何避免这一点请帮助我。

解决方案

1。我不知道你的数据库设计。但是如果添加产品代码会更好。

2.您可以在插入查询/程序之前检查现有产品名称。

2.1。您可以通过To Upper /降低双方来检查IF条件。

2.2。你可以检查IF状态,删除空间,然后上/下降两侧(我不是说要删除插入空间,我的意思是你可以使用替换方法,如果条件检查目的)。

3.在产品表中,您可以设置产品名称的唯一键类型。



对于查询帮助,你可以按照这一个



http://stackoverflow.com/questions/17442901/how-to-avoid-duplicate-values-for- insert-in-sql [ ^ ]



谢谢。


在此查看我过去的答案:如何减少重复插入表值。 [ ^ ] - 解决方案#2



-KR


存储过程中存在条件的地方

检查产品是否存在

I am doing E commerce project.i am inserted PID,Product Name in Product Table.But same Product Name inserted Multiple times in Product Table.How avoid this one please help me.

解决方案

1. I dont know about your database design. But it would better if you added a product code.
2. You can check existing product name before insert in your query/procedure.
2.1. You can check in IF condition with To Upper/ to Lower the both side.
2.2. You can check in IF condition with remove the space and to upper/to lower the both side( I am not talking to remove space for insert, I mean you can use replace method in if condition for checking purpose).
3. In product table you can set unique key type the product name.

For query help you can follow this one

http://stackoverflow.com/questions/17442901/how-to-avoid-duplicate-values-for-insert-in-sql[^]

Thanks.


See my past answer here : How to reduce the duplication insert the table values.[^] - Solution #2

-KR


place if exist condition in stored procedure
check whether the product is existed or not


这篇关于如何避免重复插入数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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