我有一个包含产品代码的表,在我的情况下,它被称为unic和产品类别,称为CatText表,它自称为sc_products。另一个名为t26_replacebleitems的表包含其中2个产品代码产品本身称为unicitem,并替换为unicreplacement。我这样询问他们:
SELECT
unicitem, unicreplacement,
sc_products.product_code, sc_products.productID,
sc_products.brief_description_ru, sc_products.name_ru,
price.postavchik as suupplier, sc_group_discounts.`action`,
sc_group_discounts.procent, price.Price as Price, price.in_stock, price.supplier
FROM
sc_products
LEFT OUTER JOIN
t26_replaceable_items ON (sc_products.unic = t26_replaceable_items.unicreplacement)
LEFT OUTER JOIN
sc_group_discounts ON (sc_products.item_group = sc_group_discounts.item_group)
LEFT JOIN
price ON (sc_products.product_code = price.item) AND (sc_products.suupplier=price.postavchik)
WHERE
t26_replaceable_items.unicitem = 'maslo1'
AND sc_products.CatText = 'nut'
AND CASE
WHEN price.Price is null
THEN price is null
ELSE price.Price = (SELECT MIN(price.Price)
FROM price
WHERE price.unic = unicreplacement)
END
GROUP BY
productID
ORDER BY
isnull (price.Price), price.Price ASC
在我更改一个产品的类别之前它工作正常,但现在它没有返回任何结果。可能存在具有相同代码和不同类别的产品。我该怎么办?