Forum Moderators: coopster
I have not been able to find a solution for my issue:
Say I have a MySQL table "products" with four fields:
ID, merchant, item, price
I have a second MySQL table "shipping" with three fields:
ID, merchant, shippingcost
Now, as you can imagine, my idea is to display a table with the following columns:
merchant, item, price, shippingcost, total
I have done a LEFT JOIN to display the shipping cost. Works.
The column total is generated dynamically
$total = $row['price'] + $row['shippingcost'];
Now, I want to sort the table by column total from lowest to highest.
Of course, ORDER BY after the SELECT statement wouldn't work, as total is not actually a field of either table.
It is also not possible to calculate the total and add it as a field to table "products" before all the data is imported into the database (the whole example is very simplified).
Any ideas or work-arounds?
Cheers,
Chris