Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > MySQL > Discount-calculation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-11-03, 10:59
m_roos81 m_roos81 is offline
Registered User
 
Join Date: Jul 2003
Location: Hoofddorp - The Netherlands
Posts: 9
Exclamation Discount-calculation

Hello everybody,

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):

- discount
- discount_id
- product_id
- company_id
- productdiscount

- companies
- company_id
- companydiscount

- users
- user_id
- company_id

- products
- product_id
- name
- price

The first thing that has to be calculated is the companydiscount.
And for the products that have a alternative discount, I of course want to show that alternatvie discount.

I wrote the following SQL-script:

select products.product_id, products.name, products.price, discount.discount_id, discount.product_id, discount.company_id, discount.productdiscount, companies.company_id, companies.companiediscount, users.user_id, users.company_id,

(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?

I hope anyone can help me!

Many thanks,

Michael Roos
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On