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 Quote 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. Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.