특정 if 조건을 사용하여 mysql 쿼리를 작성하려고합니다.특정 IF ELSE가있는 MySQL 쿼리 ELSE 조건 인 경우
내 DB 구조
환율 (표)
if (amt_curr=='USD') {
$totalinr = (amt_paid * rate); (rate it should take from currency table where currency='USD' from currency table)
} else if ($currency1=='GBP'){
totalinr = ((select currency, rate from Currency where currency=INR/0.761203 (GBP value from currency table)) * amt_paid);
} else if ($currency1=='EUR'){
totalinr = ((select currency, rate from Currency where currency=INR/0.89295 (EUR value from currency table)) * amt_paid);
}
스피 MySQL의 쿼리와이를 달성하기 위해 노력하는 경우
++++++++++++++++++++++++++
id | currency | rate
++++++++++++++++++++++++++
1 USD 1
2 INR 67.10043
3 GBP 0.761203
4 EUR 0.89295
++++++++++++++++++++++++++
com_payments (Table)
++++++++++++++++++++++++++
id | amt_curr | amt_paid
++++++++++++++++++++++++++
1 EUR 300.89
2 GBP 390.90
3 USD 600.00
++++++++++++++++++++++++++
내가 찾고 있어요 쿼리가이다 : 뭔가 시도 이 기능은 작동하지 않습니다.
CASE WHEN (amt_curr=='USD') THEN (amt_paid * rate) (rate it should take from currency table where currency='USD' from currency table)
WHEN ($currency1=='GBP') THEN ((select currency, rate from Currency where currency=INR/0.761203 (GBP value from currency table)) * amt_paid)
WHEN ($currency1=='EUR') THEN ((select currency, rate from Currency where currency=INR/0.89295 (EUR value from currency table)) * amt_paid)
END AS totalinr
사람이이 PLS에 나를 도와? –