I have this part of a query:
(@tmpo1245 := CAST( ( ( pm5.`meta_value` - pm4.`meta_value` ) / 86400 ) AS SIGNED ) ) AND
(@mutdate:=DATE_SUB( '2011-06-1', INTERVAL @tmpo1245 DAY ) ) AND
Which is causing my query to fail. I know CAST( ( ( pm5.meta_value- pm4.meta_value) / 86400 ) AS SIGNED ) is 5, I put it in a select statement to test it. I also know the following query works just fine:
(@tmpo1245 := 5 ) AND
(@mutdate:=DATE_SUB( '2011-06-1', INTERVAL @tmpo1245 DAY ) ) AND
What is going on?
It seems the error is with the clause inside the CAST in your query. I guess the data types of pm5.
meta_valueand pm4.meta_valueyour are trying to subtract are not numeric. Hence please cast them decimals first before subtracting. Example code would be as follows.