大家好我有以下查询
SELECT DISTINCT
t15_catalogue_line.T15_GROUP,
sc_products.product_code,sc_products.unic,
sc_products.name_ru,
UPPER(TRIM(sc_products.brief_description_ru)) AS brief_description_ru,
sc_products.suupplier,
price.Price,
sc_group_discounts.`action`,
sc_group_discounts.procent,
sc_products.productID,
price.in_stock,
price.supplier,
t10_item.T10_ITEM,
t10_item.T10_DESC,
t10_item.T10_IMG,
t10_item.T10_ITEM_GROUP,
t10_item.T10_FIELD1,
t10_item.T10_FIELD2,
t10_item.T10_FIELD3,
t10_item.T10_FIELD4,
t10_item.T10_FIELD5,
t10_item.T10_FIELD6,
t10_item.T10_FIELD7,
t10_item.T10_FIELD8,
t10_item.T10_FIELD9,
t10_item.T10_FIELD10,
t10_item.T10_FIELD11,
t14_item_fields.T14_ITEM_GROUP,
t14_item_fields.T14_FIELD,
t14_item_fields.T14_NAME,
t14_item_fields.T14_UNIT,
t14_item_fields.T14_SEARCH
FROM
sc_products
LEFT OUTER JOIN t15_catalogue_line ON (sc_products.unic = t15_catalogue_line.unic)
LEFT OUTER JOIN price ON (sc_products.unic = price.unic)
AND (sc_products.suupplier = price.postavchik)
LEFT OUTER JOIN sc_group_discounts ON (sc_products.item_group = sc_group_discounts.item_group)
LEFT OUTER JOIN t10_item ON (sc_products.product_code = t10_item.T10_ITEM)
LEFT OUTER JOIN t14_item_fields ON (t10_item.T10_ITEM_GROUP = t14_item_fields.T14_ITEM_GROUP)
WHERE
t15_catalogue_line.T15_CARTYPE = '30416' AND
t15_catalogue_line.T15_GROUP = '546678'
and sc_products.unic is not null and sc_products. unic!=''
GROUP BY
t15_catalogue_line.unic
表格看起来像这样 t15_catalog_line: t15_ITEM来自供应商的产品代码, t15_cartype适用于所需部件的汽车型号 t15_group组件破坏系统ets。 网站上的unic产品代码。它不是唯一的,因此它在其他表格中重复,并且对于不同的部分可能存在与病毒相同的产品代码。问题是,如果发生这种设置,查询返回第一行,它是mached disgarding where子句。如何修复?
答案 0 :(得分:0)
完全删除group by
子句。
MySQL允许非标准使用group:如果您使用group by
,但grouo by
中未列出某些非聚合列,则每个组合的唯一组合会得到一行列。
这不是你想要的。