当我将产品添加到woocommerce 4.4.1时,出现错误消息

时间:2020-08-30 15:14:13

标签: mysql wordpress woocommerce product

当我尝试将产品添加到wordpresss-> woocomerce时,出现错误消息:

WordPress数据库错误:[您的SQL语法有错误;请检查与您的MySQL服务器版本对应的手册,以在')附近使用正确的语法,或者在第5行p.product_id = 30582 OR g.apply_to ='all'GROUP BY g.id ORDER BY g']

SELECT 
    g.*
    , GROUP_CONCAT(DISTINCT c.category_id) as `categories`
    , GROUP_CONCAT(DISTINCT p.product_id) as `products` 
FROM wpav_za_groups as g 
    LEFT JOIN wpav_za_categories_to_groups as c ON c.group_id = g.id 
    LEFT JOIN wpav_za_products_to_groups as p ON p.group_id = g.id 
WHERE 
    c.category_id IN () 
    OR p.product_id = 30582 
    OR g.apply_to = 'all' 
GROUP BY g.id 
ORDER BY g.priority ASC

您能帮助检查问题所在吗?

1 个答案:

答案 0 :(得分:1)

您在IN子句中缺少文本或数据

c.category_id IN ('test1','teswt2') 

您必须输入自己的文本或数据,而不是text1和test2

SELECT 
    g.*
    , GROUP_CONCAT(DISTINCT c.category_id) as `categories`
    , GROUP_CONCAT(DISTINCT p.product_id) as `products` 
FROM wpav_za_groups as g 
    LEFT JOIN wpav_za_categories_to_groups as c ON c.group_id = g.id 
    LEFT JOIN wpav_za_products_to_groups as p ON p.group_id = g.id 
WHERE 
    c.category_id IN ('test1','teswt2') 
    OR p.product_id = 30582 
    OR g.apply_to = 'all' 
GROUP BY g.id 
ORDER BY g.priority ASC