Reputation: 440
Im facing a problem with change column value within selected date range. Simply i want to disable all products (set 0 value instead of 1) within a desired date range like below:
My query is
SELECT * FROM `product`
WHERE `date_add` > '2015-08-01 00:00:00'
AND `date_upd` < '2016-08-01 00:00:00'
SET `active` = 0
But PHPMyAdmin throws error
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET
active
= 0 ORDER BYproduct
.date_upd
ASC LIMIT 0, 30' at line 5
Upvotes: 0
Views: 741
Reputation: 2436
Use Update Query Instead of select.
The UPDATE statement is used to update records in a table.
update `product`
set `active`='0'
WHERE `date_add` > '2015-08-01 00:00:00'
AND `date_upd` < '2016-08-01 00:00:00'
Upvotes: 1
Reputation: 154
You're supposed to use an UPDATE
Statement to change a value
UPDATE product
SET active = 0
WHERE date_add > '2015-08-01 00:00:00'
AND date_upd < '2016-08-01 00:00:00'
Here's to documentation: http://dev.mysql.com/doc/refman/5.7/en/update.html
Upvotes: 2