Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
MySQLテーブルtotalとに2つの列がありdollarsます。ドルをルピーに換算して、自分のtotalフィールドに保管する必要があります。ライブドルレートを掛けて結果を保存できますか?
total
dollars
次のような数学関数のSQLクエリが必要です。
total = dollars * current_dollar_rate_in_rupees
この変換を動的にすることはできますか?もしそうなら、どのようにそして私のSQLクエリは何でしょうか?
次のクエリを使用して、変換結果をtotalフィールドに格納できます。
UPDATE `tablename` SET `total` = `dollars` * <current_dollar_rate_in_rupees>;
SQLServerで2つの列を乗算する
したがって、このクエリによって提供される値を「合計」としてデータベースに保存するだけです。
SELECT dollars * current_dollar_rate_in_rupees from tablename