brucegregory Posted May 16, 2012 Share Posted May 16, 2012 Is it possible to put a multiplication problem in the mysql "default value" field? In my script I need to take the unit amount * quantity, I know how to do this in php, but can I just put my equation in the "default value" field in MYSQL and make it equal to another field?... Like excell? Thanks Link to comment https://forums.phpfreaks.com/topic/262641-is-it-possible-to-put-a-multiplication-problem-in-the-mysql-default-value/ Share on other sites More sharing options...
rythemton Posted May 16, 2012 Share Posted May 16, 2012 From MySQL website(http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html): The DEFAULT value clause in a data type specification indicates a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression. It appears that you can't do this. Link to comment https://forums.phpfreaks.com/topic/262641-is-it-possible-to-put-a-multiplication-problem-in-the-mysql-default-value/#findComment-1346139 Share on other sites More sharing options...
requinix Posted May 16, 2012 Share Posted May 16, 2012 You shouldn't need to store the result of an equation in the table because you can just do the math whenever you want it. Like in a VIEW or SELECT or, of course, in your code. Link to comment https://forums.phpfreaks.com/topic/262641-is-it-possible-to-put-a-multiplication-problem-in-the-mysql-default-value/#findComment-1346141 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.