嗨條款都是我有以下查詢無法實現其中MySQL查詢
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。 在網站上的單一產品代碼。它不是獨一無二的,所以它在其他表格中重複,並且可能有不同部件的相同產品代碼。這個問題是,如果這個設置發生查詢返回第一行是mached disgarding where子句。如何解決這個問題?
乍一看: 您正在選擇DISTINCT組,並在where子句中要求提供一個組ID。據我所知,這應該只返回1個結果,即'546678'組。 –