I have a query where i want to filter a list of results but base it on a percentage between 2 values.
I have two databases 'Amazon' and 'Zavvi' in both of these databases i have the same products and how much they sell for and was filtering the results using the following
SELECT amazon.price AS amazon_price, zavvi.price AS zavvi_price
FROM amazon.price, zavvi.price
WHERE amazon.price > zavvi.price
However i want to work out the percentage of the two prices, and then display only records where are a percentage of that amount, but do it all within a query if possible.
at the moment i have to use the above query i have given an example too, and then within a loop do a IF statement which calculates the percentage for each record and then if it meets my needs add it to an array like so.
$myrow['percent'] = number_format((100/$myrow['amazon_price'])*$myrow['zavvi_price'],0);
if ($myrow['percent'] >= 80) {