I want to get the result of the multiplication between column fee and column duration, but when I do Select duration * fee I get 0!
Also, every column * fee gives me 0...
This is the create table script.
delimiter $$
CREATE TABLE `simvoip`
(
`prefix` varchar(45) DEFAULT NULL,
`destination` varchar(45) DEFAULT NULL,
`fee` varchar(45) DEFAULT NULL,
`calldate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`dst` varchar(80) CHARACTER SET latin1 NOT NULL DEFAULT '',
`dstchannel` varchar(80) CHARACTER SET latin1 NOT NULL DEFAULT '',
`duration` varchar(45) DEFAULT '0'
) ENGINE=InnoDB DEFAULT
CHARSET=utf8$$*
解决方案
In order to achieve what you want, you need to convert string columns into number.
try this:
SELECT CAST(`duration` AS DECIMAL(10,4)) * CAST(`fee` AS DECIMAL(10,4))
FROM `simvoip`
BTW, you are adding extra work for the server to convert the values first before multiplying them. Why not store the as DECIMAL or Double?