I've just discovered that MySQL has an IF function
It could be very useful to do some simple conditional numeric calculations in MySQL. Especially where a particular report outputs in several different formats, could cut 50 lines of PHP out of each report
Just wondering though, is it advised to use it?
Or is it always best to handle that sort of thing in the programming language (PHP)?
A simple example of what I currently do in PHP is:
Code: Select all
if ($currency == 'EUR') {
$total_gbp = $total / $exchange_rate_eur;
} elseif ($currency == 'USD') {
$total_gbp = $total / $exchange_rate_usd;
} else {
$total_gbp = $total;
}Thanks, B