当我运行时,这个查询出现了错误
app.UseOAuthAuthorizationServer(new OAuthAuthorizationServerOptions()
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider(),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(300),
AllowInsecureHttp = true
});
当我添加
INSERT IGNORE INTO an_catalogsearch_fulltext (product_id, store_id, data_index)
SELECT DISTINCT ca_ent.entity_id as product_id,
4 as store_id,
CONCAT(
ifnull(ca_var.value,''),' ',
ifnull(ca_ent.sku,''), ' ',
ifnull(
(
SELECT GROUP_CONCAT( ca_ent2.sku) FROM `an_catalog_product_entity` ca_ent2 LEFT JOIN `an_catalog_product_super_link` ca_sup
ON ca_sup.product_id = ca_ent2.entity_id WHERE ca_sup.parent_id = ca_ent.entity_id GROUP BY ca_sup.parent_id
),'') ,' ',
ifnull(
(
SELECT GROUP_CONCAT( ca_ent3.sku) FROM `an_catalog_product_entity` ca_ent3 LEFT JOIN `an_catalog_product_link` ca_lin
ON ca_lin.linked_product_id = ca_ent3.entity_id WHERE ca_lin.product_id = ca_ent.entity_id GROUP BY ca_lin.product_id
),'') ,' ',
ifnull(ca_text.value,'') , ' ',
ifnull(
select option_value.value from `an_eav_attribute_option_value` as option_value where option_value.option_id = an_alt_norm_form.value, '')
) as data_index FROM `an_catalog_product_entity` ca_ent
LEFT JOIN `an_catalog_product_entity_varchar` ca_var ON ca_var.entity_id = ca_ent.entity_id AND ca_var.attribute_id = 71
LEFT JOIN `an_catalog_product_entity_text` ca_text ON ca_text.entity_id = ca_ent.entity_id AND ca_text.attribute_id = 72
LEFT JOIN `an_catalog_product_entity_int` an_alt_norm_form ON an_alt_norm_form.entity_id = ca_ent.entity_id AND an_alt_norm_form.attribute_id = 306 ;
他们给我一个语法错误
当我用简单的ifnull(select option_value.value from `an_eav_attribute_option_value` as option_value where option_value.option_id = an_alt_norm_form.value, '')
替换此行时,我正在做错的
答案 0 :(得分:1)
INSERT IGNORE INTO an_catalogsearch_fulltext (product_id, store_id, data_index)
SELECT DISTINCT ca_ent.entity_id as product_id,
4 as store_id,
CONCAT(
ifnull(ca_var.value,''),' ',
ifnull(ca_ent.sku,''), ' ',
IFNULL((SELECT GROUP_CONCAT( ca_ent2.sku) FROM `an_catalog_product_entity` ca_ent2 LEFT JOIN `an_catalog_product_super_link` ca_sup
ON ca_sup.product_id = ca_ent2.entity_id WHERE ca_sup.parent_id = ca_ent.entity_id GROUP BY ca_sup.parent_id
),'') ,' ',
IFNULL((SELECT GROUP_CONCAT( ca_ent3.sku) FROM `an_catalog_product_entity` ca_ent3 LEFT JOIN `an_catalog_product_link` ca_lin
ON ca_lin.linked_product_id = ca_ent3.entity_id WHERE ca_lin.product_id = ca_ent.entity_id GROUP BY ca_lin.product_id),'') ,' ',
ifnull(ca_text.value,'') , ' ',
IFNULL((select option_value.value from `an_eav_attribute_option_value` as option_value where option_value.option_id = an_alt_norm_form.value),'') ,' ') as data_index FROM `an_catalog_product_entity` ca_ent
LEFT JOIN `an_catalog_product_entity_varchar` ca_var ON ca_var.entity_id = ca_ent.entity_id AND ca_var.attribute_id = 71
LEFT JOIN `an_catalog_product_entity_text` ca_text ON ca_text.entity_id = ca_ent.entity_id AND ca_text.attribute_id = 72
LEFT JOIN `an_catalog_product_entity_int` an_alt_norm_form ON an_alt_norm_form.entity_id = ca_ent.entity_id AND an_alt_norm_form.attribute_id = 306 ;
尝试以上查询。
答案 1 :(得分:1)
将您使用的语法与现有的ifnull
语句进行比较:
ifnull(
(
SELECT GROUP_CONCAT( ca_ent2.sku) FROM `an_catalog_product_entity` ca_ent2 LEFT JOIN `an_catalog_product_super_link` ca_sup
ON ca_sup.product_id = ca_ent2.entity_id WHERE ca_sup.parent_id = ca_ent.entity_id GROUP BY ca_sup.parent_id
),'')
在这里,您将子查询包装在另一组括号中,但是使用新添加的
ifnull(select option_value.value from `an_eav_attribute_option_value` ..., '')
缺少那些。