I have this query, which works...
UPDATE `contacts`
SET `calls_to`=`calls_to`+1
WHERE `contact_no` = '0412345678';
What I also want to do is add a value to the cost field. From my understanding, the way to do this would be...
UPDATE `contacts`
SET `calls_to` = `calls_to`+1,
`cost_to` = `cost_to`+0.25
WHERE `contact_no`='0412345678';
Obviously, as I'm posting here, it's not working as I would expect.
--UPDATE--
As requested, the table structure..
id int(255) auto_increment
contact_owner varchar(255)
contact_no varchar(11)
contact_name varchar(255)
calls_to int(255)
txts_to int(255)
time_talked_to int(255)
cost_to decimal(65,2)
Check if the datatype for cost_to
is int or not.Also update the column if it's value is not null.
UPDATE `contacts`
SET `calls_to` = `calls_to`+1,
`cost_to` = `cost_to`+0.25
WHERE `contact_no`='0412345678' AND
calls_to is not null AND
cost_to is not null;
On first glance the query looks fine. What is the type of the cost_to
field? Double check it's not an integral type, since you will then not get the result you are looking for. (As a test, add a larger value, say, 4 to cost_to.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With