【发布时间】:2015-12-12 09:51:09
【问题描述】:
我已将 magento 版本从 1.4.2 升级到 1.8,当我将某些东西添加到购物车时出现 SQL 错误:
SQLSTATE[42S22]:找不到列:1054 'where 子句'中的未知列 'website_ids'
导致此错误的 SQL 查询:
SELECT `main_table`.*
FROM `salesrule` AS `main_table`
WHERE (is_active=1)
AND (find_in_set(1, website_ids))
AND (find_in_set(0, customer_group_ids))
AND (main_table.coupon_type = 1)
AND (from_date is null or from_date<='2015-12-12')
AND (to_date is null or to_date>='2015-12-12')
ORDER BY `sort_order` ASC
我知道我应该准备一些 sql 查询来修复它,但我不擅长 sql。有人有解决方案吗?谢谢。
销售规则定义:
CREATE TABLE `salesrule` (
`rule_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Rule Id',
`name` varchar(255) DEFAULT NULL COMMENT 'Name',
`description` text COMMENT 'Description',
`from_date` date DEFAULT NULL,
`to_date` date DEFAULT NULL,
`uses_per_customer` int(11) NOT NULL DEFAULT '0' COMMENT 'Uses Per Customer',
`is_active` smallint(6) NOT NULL DEFAULT '0' COMMENT 'Is Active',
`conditions_serialized` mediumtext COMMENT 'Conditions Serialized',
`actions_serialized` mediumtext COMMENT 'Actions Serialized',
`stop_rules_processing` smallint(6) NOT NULL DEFAULT '1' COMMENT 'Stop Rules Processing',
`is_advanced` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'Is Advanced',
`product_ids` text COMMENT 'Product Ids',
`sort_order` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Sort Order',
`simple_action` varchar(32) DEFAULT NULL COMMENT 'Simple Action',
`discount_amount` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Discount Amount',
`discount_qty` decimal(12,4) DEFAULT NULL COMMENT 'Discount Qty',
`discount_step` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Discount Step',
`simple_free_shipping` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Simple Free Shipping',
`apply_to_shipping` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Apply To Shipping',
`times_used` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Times Used',
`is_rss` smallint(6) NOT NULL DEFAULT '0' COMMENT 'Is Rss',
`coupon_type` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'Coupon Type',
`use_auto_generation` smallint(6) NOT NULL DEFAULT '0' COMMENT 'Use Auto Generation',
`uses_per_coupon` int(11) NOT NULL DEFAULT '0' COMMENT 'Uses Per Coupon',
PRIMARY KEY (`rule_id`),
KEY `IDX_SALESRULE_IS_ACTIVE_SORT_ORDER_TO_DATE_FROM_DATE` (`is_active`,`sort_order`,`to_date`,`from_date`)
) ENGINE=InnoDB AUTO_INCREMENT=209 DEFAULT CHARSET=utf8 COMMENT='Salesrule'
【问题讨论】:
-
发布 main_table 的表定义 (
show create table main_table) -
好吧,
website_ids不在该表中。也许您的意思是product_ids,但如果没有更多上下文就不可能知道。 customer_group_ids 也不存在