日期:2014-05-16  浏览次数:20846 次

mysql 作为计算器使用

mysql> set @daily_room_charge = 100;

Query OK, 0 rows affected (0.02 sec)

?

mysql> set @num_of_nights = 3;

Query OK, 0 rows affected (0.00 sec)

?

mysql> set @tax_percent = 8;

Query OK, 0 rows affected (0.00 sec)

?

mysql> set @total_room_charge = @daily_room_charge * @num_of_nights;

Query OK, 0 rows affected (0.00 sec)

?

mysql> set @tax = (@total_room_charge * @tax_percent)/100;

Query OK, 0 rows affected (0.02 sec)

?

mysql> set @total = @total_room_charge + @tax;

Query OK, 0 rows affected (0.00 sec)

?

mysql> select @total;

+---------------+

| @total ? ? ? ?|

+---------------+

| 324.000000000 |

+---------------+

1 row in set (0.02 sec)