Reputation: 73
This may seem like a stupid question but i have a table which is populated by a SQL query. Here is the query and table:
select Products, Quantity, Price FROM Products ORDER BY Price ASC
Now this is getting stored in a table using php. How can show what the price per unit is.. i.e. Price/Quantity and display it on the table for each corresponding row?
I have not shown price per unit on the database just the total price for the quantity.. Is this a wise thing to do or should I show price per unit before hand?
Anyway... Does anyone know how I can do this In php?? I believe I might need to use the 'AS'
keyword?
Thanks.
Upvotes: 0
Views: 1752
Reputation: 1385
select Products, Quantity, Price, (Price/Quantity) as PricePerUnit FROM Products ORDER BY Price ASC
Upvotes: 3