简体   繁体   English

我在表格中有两列,例如品牌和产品,那么如何防止同一品牌的产品插入?

[英]I have Two Column in a Table like brand and product so how I prevent same product insert in same brand?

Suppose I have two column one is brand and other is product and there is a data like samsung and galaxy j8. 假设我有两列,一个是品牌,另一个是产品,并且有像三星和银河j8这样的数据。 If I insert again samsung and galaxy j8 it shows me error. 如果我再次插入三星和银河j8,则显示错误。 So how to do this ? 那么该怎么做呢?

From the database itself prevent duplicate insertion of two column use constrain like this 从数据库本身防止两列重复插入使用constrain像这样

ALTER TABLE table_name
ADD CONSTRAINT constrain_name UNIQUE (brand,product);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQL从一个表中选择品牌,如果另一个表具有该品牌的产品 - SQL to select brand from a table, if another table has a product with that brand 显示产品品牌 - Showing product brand 如何在 Woocommerce 后端正确过滤特定产品属性(在本例中为品牌) - How do I correctly filter by a specific product attribute (Brand in this case) in Woocommerce backend 如何在 WooCommerce 中获取产品的品牌名称 - How to get the brand name of product in WooCommerce 以编程方式导入 WooCommerce 产品时如何设置产品品牌? - How to set product brand when programatically importing WooCommerce product? Laravel Eloquent:如何按产品类别和/或产品品牌过滤产品评论? - Laravel Eloquent: how to filter reviews of products by product category and/or product brand? 如何在 Woocommerce 中拥有相同的店铺基础和产品基础 - How can I have shop base and product base the same in Woocommerce SeoShop API +如何在带有curl的PHP产品中添加品牌 - SeoShop API + how to add brand within the product in php with curl 如何在Magento Soap API中按类别和品牌过滤产品列表 - How to filter product list by category and brand in Magento soap api 按品牌显示包含产品信息的关联数组 - display associative array containing product info brand by brand
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM