I'm busy with a website with a MySQL-database, and I want to build in a discount-calculation. Customers who log in at the have their own general discount, but there can be an exception for a few products.
I have the following tables and fields (only the ones I use in the script):
(price)-(price/100*productdiscount) as alternative_discount,
(price)-(price/100*companydiscount) as general_discount
from products, companies, users, discount
where companies.company_id = users.company_id and
products.product_id = discount.producte_id
The only thing that happens now is that only the product that have an anlternative discount are showed. How can I make a script that show all the products with the general discount, but the products with the alternative discount with the right calculated discount?
Well, you should be posting this in the MySQL forum, but I can see right off that you haven't linked your Companies and Discounts tables. You are essentially running a crossjoin query, and I don't think that is your intention.