Welcome Guest, Not a member yet? Register   Sign In
SQL: SET column1+=value
#1

[eluser]Volkof[/eluser]
Hi everyone,

I'm wondering if there is a way to do this:

Code:
$sql = "UPDATE Review
  SET numHelpful +=".$numHelpful.", numNotHelpful +=".$numNotHelpful."
  WHERE reviewID =".$reviewID;

Basically what is happening is that i'm creating a voting system. If user click 'isHelpful', then in DB the column value will be incremented by 1. Same goes for 'NotHelpful'.

I was wondering if you can straight away += into database, rather than get from DB, increment by 1, then update back in. But apparently the former method doesnt work.


Messages In This Thread
SQL: SET column1+=value - by El Forum - 01-03-2013, 12:24 AM
SQL: SET column1+=value - by El Forum - 01-03-2013, 01:13 AM
SQL: SET column1+=value - by El Forum - 01-03-2013, 01:41 AM
SQL: SET column1+=value - by El Forum - 01-03-2013, 02:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB