Reputation: 337
I have this query below which doesn't seem to work. In 1 blow I wanted to update all rows who's current price is NOT equal to temporary price. I want the column prevprice to copy or be the same as the column currprice.
It does not give any errors, but it never updates the prevprice.
$PreviousPrices = mysqli_query($conn,"UPDATE allproducts WHERE temporaryprice != currprice SET prevprice=currprice");
Upvotes: 1
Views: 632
Reputation: 4105
SET
comes before WHERE
UPDATE allproducts SET prevprice = currprice WHERE temporaryprice != currprice
And, yes, !=
is valid MySQL:
http://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#operator_not-equal
Upvotes: 4
Reputation: 33933
Whooo... You're in SLQ language here.
!=
is not recognised.
<>
may be better...
For logic operators see here: http://www.w3schools.com/sql/sql_where.asp
Or read more on the LIKE operator here : http://www.w3schools.com/sql/sql_like.asp
EDIT
And yes, as comments says below your question, there is at least a missing «SET column_name='value'»...
Upvotes: -1