I have a dynamic variable in php $newtotal. I want to INSERT when this variable is Greater than my MAX Database Integer
$newtotal = 4000;
mysql_query("INSERT INTO mytable (`DATE`, `TOTAL`, `DBTOTAL`) VALUES ('2012-03-09', '1', '$newtotal') WHERE MAX(`DBTOTAL`) < '$newtotal'");
ie. And in my database my MAX(DBTOTAL) = 4050;
This should not INSERT; also it should INSERT correctly when $newtotal is changed to greater than 4050 however I get syntax errors on either variable number. Need help with the syntax here.
You cannot use
WHEREclauses inINSERTstatements. You will need to check the value to see if you want to insert and do so if your conditions are met.For example: