Jump to content

Dealing with money in MySQL & Joining Tables


BCAV_WEB

Recommended Posts

Hi,

 

I have a two parter question completely different.

 

1. I need to have two money figures saved to my database "RRP" and "our price" and with this I would like to work out the savings. Easy enough to do, however how do I get the int number to display as £4,567.00 for example?

 

[

$savings = $row["rrp"] - $row["our_price"];

]

 

2. Part two of my question I have a database that stores cars, so models makes etc... but I also need to store colours for each car, so the colour name and the colour colour. What would be the best way of doing this? Remembering that a single car can have many many colours.

 

Any ideas and thought would be much appericated.

 

Thank you

The DECIMAL column type must be one of the options -- I've always used alter statements.

 

As for linking them together, you'll need 3 tables -- colors, cars, and the relation table.  Simply store a uid tuple in the latter.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.