Hallo zusammen habe ich die folgende Abfragekann nicht implementieren, wo Klausel in mysql Abfrage
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
Die Tabelle ist wie dieses t15_catalog_line aussehen: t15_ITEM Produktcode von Lieferanten, t15_cartype Automodell für Weichen benötigte Teile t15_group Teilegruppe Break System ets. Unicode-Produktcode auf einer Website. Es ist nicht einzigartig, so dass es in anderen Tabellen doppelt vorhanden ist und es könnte seviral die gleichen Produktcodes für verschiedene Teile geben. Das Problem ist, dass, wenn diese Einstellung passiert, Abfrage die erste Zeile zurückgibt, die von der where-Klausel manipuliert wird. Wie könnte das behoben werden?
Aus dem ersten Blick: Sie wählen DISTINCT Gruppe, und in der Where-Klausel fragen Sie nach einer einzelnen Gruppe ID. Soweit ich das beurteilen kann, sollte das nur 1 Ergebnis zurückgeben, nämlich die Gruppe "546678". –