Jump to content

[SOLVED] Mysql UPDATE problem


n3mesis125

Recommended Posts

Hey Guys,

 

I'm using the below query and for whatever reason it keeps throwing an error:

 

UPDATE `csit_actioned`
SET `green` = IF(SUM(UNIX_TIMESTAMP(entry_date) - UNIX_TIMESTAMP(rec_date)) <= 194400,1,0),
SET `yellow` = IF(SUM(UNIX_TIMESTAMP(entry_date) - UNIX_TIMESTAMP(rec_date)) BETWEEN '194400' AND '259201',1,0),
SET `red` = IF(SUM(UNIX_TIMESTAMP(entry_date) - UNIX_TIMESTAMP(rec_date)) > 259200,1,0)
WHERE id='294739'

 

The error i get is:

#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 `yellow` = IF(SUM(UNIX_TIMESTAMP(entry_date) - UNIX_TIMESTAMP(rec_date)) BET' at line 3

 

 

PS: Using PHP5 and MYSQL 5.0.67

 

Link to comment
https://forums.phpfreaks.com/topic/132709-solved-mysql-update-problem/
Share on other sites

You should only use SET once, the first time.

 

UPDATE `csit_actioned`

SET `green` = IF(SUM(UNIX_TIMESTAMP(entry_date) - UNIX_TIMESTAMP(rec_date)) <= 194400,1,0),

`yellow` = IF(SUM(UNIX_TIMESTAMP(entry_date) - UNIX_TIMESTAMP(rec_date)) BETWEEN '194400' AND '259201',1,0),

`red` = IF(SUM(UNIX_TIMESTAMP(entry_date) - UNIX_TIMESTAMP(rec_date)) > 259200,1,0)

WHERE id='294739'

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.