MySQL Forums
Forum List  »  PHP

Re: Help with a bad query
Posted by: Felix Geerinckx
Date: August 16, 2005 08:35AM

J Kahn wrote:

> UPDATE data SET status='2' AND history='edited' WHERE jobnum='5'
> I can't understand why the statment is wrong, can anyone help?

This should be

UPDATE data SET status = '2', history = 'edited' WHERE jobnum = '5';

(note the comma instead of the AND)

Your statement in fact is equivalent to

UPDATE data SET status = ('2' AND history = 'edited') WHERE jobnum = '5';

Which sets
status = 1 when history = 'edited' or
status = 0 when history != 'edited'

(Note: are your status and jobnum CHAR/VARCHAR? If not, don't use the single quotes around the 2 and 5 literals)

Please use BBCode to format your messages in this forum.

Options: ReplyQuote

Written By
August 16, 2005 07:30AM
August 16, 2005 08:15AM
Re: Help with a bad query
August 16, 2005 08:35AM
August 16, 2005 08:39AM
August 16, 2005 08:44AM
August 16, 2005 08:51AM
August 16, 2005 10:25AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.