Announcement

Collapse
No announcement yet.

MySQL Abfrage liefert zwei Datensätze, aber nur einer soll angezeigt werden

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Ich war zwischenzeitlich in Urlaub und der Kollege kann hier immernoch nicht mitreden.
    So funktioniert es jetzt:

    Code:
    "select p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, 
    (CASE WHEN cd2.product_id !=0 THEN p.products_price*(100-cd2.Rabatt)/100 ELSE p.products_price*(100-cd.Rabatt)/100 end) as final_price 
    from " . TABLE_PRODUCTS . " p 
    left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id 
    LEFT JOIN " . TABLE_CUSTOMERS_DISCOUNT  . " cd on cd.customers_id ='" .(int) $customer_id. "'and cd.categories_id = '" .(int) $current_category_id. "' and cd.product_id ='0' 
    left join " . TABLE_CUSTOMERS_DISCOUNT  . " cd2 on cd2.customers_id ='" .(int) $customer_id. "'and cd2.categories_id = '" .(int) $current_category_id. "'and cd2.product_id =  p.products_id, 
    " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c 
    where p.products_status = '1' 
    and p.manufacturers_id = m.manufacturers_id 
    and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' 
    and p.products_id = p2c.products_id and pd.products_id = p2c.products_id 
    and pd.language_id = '" . (int)$languages_id . "' 
    and p2c.categories_id = '" . (int)$current_category_id . "'";
    Nochmals vielen Dank
    Günther

    Comment

    Working...
    X