Hi

Building an e-commerce store,

got a product table, with a price field
got a discounts table with product_id, and an active field

my query left joins discounts onto products, but I only want to pull in the discount if discount.active = '1'... but if I use 'WHERE discount.active = '1' ' - then it restricts all products to ones with an active discount...

help!

select price * (1 - if(discount_active, 0.1, 0 )) as retail_price

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.