sql 目录类别索引外键错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 目录类别索引外键错误相关的知识,希望对你有一定的参考价值。

#http://stackoverflow.com/questions/29673696/magento-category-products-reindex-error/29676254#29676254

delete from `catalog_category_product` WHERE product_id not in(select entity_id from `catalog_product_entity`);
delete from `catalog_category_product` WHERE category_id not in(select entity_id from catalog_category_entity); 
delete from `catalog_product_website` WHERE product_id not in(select entity_id from catalog_product_entity); 
delete from `catalog_product_index_eav_idx` WHERE entity_id not in(select entity_id from catalog_product_entity); 
delete from `catalog_product_index_eav` WHERE entity_id not in(select entity_id from catalog_product_entity); 
delete from `catalog_product_link` WHERE product_id not in(select entity_id from catalog_product_entity); 
delete from `catalog_product_relation` WHERE parent_id not in(select entity_id from catalog_product_entity);
DELETE from `sales_flat_quote_shipping_rate` WHERE `address_id` not in(select `address_id` from `sales_flat_quote_address`);

# Determine incorrect product associations
SELECT * FROM `catalog_category_product` WHERE
product_id not in (select entity_id from catalog_product_entity);

# Determine incorrect categories
SELECT * FROM `catalog_category_product` WHERE 
category_id not in (select entity_id from catalog_category_entity);

# Delete incorrect product associations
DELETE FROM `catalog_category_product` WHERE 
product_id not in (select entity_id from catalog_product_entity);

# Delete incorrect categories
DELETE FROM `catalog_category_product` WHERE 
category_id not in (select entity_id from catalog_category_entity);

以上是关于sql 目录类别索引外键错误的主要内容,如果未能解决你的问题,请参考以下文章

我应该使用外键在 SQL 中显示树关系吗

sql 没有索引的外键:创建CREATE查询

外键和主键的 Postgres 和索引

sql 语句系列(列举非索引外键)[八百章之第九章]

SQL Server 使用 2 个表(外键?) ASP.NET

MySQL 下拉字段;外键错误号 150