Page 1 of 1

update multiple fields

Posted: Mon Aug 07, 2006 8:33 am
by ziggy1621
here is an easy one.. I'm just having a brain fart...

I want to update multiple fields chronologically by the "id" field.

Something like this in theory (but my syntax is off)

Code: Select all

UPDATE `table` SET `field` = 'blah' WHERE `id` = '1-7';"
thanks in advance

Posted: Mon Aug 07, 2006 9:06 am
by JayBird

Code: Select all

UPDATE `table` SET `field1` = 'blah', `field2` = 'blah', `field3` = 'blah' WHERE `id` = '1-7'

Posted: Mon Aug 07, 2006 9:22 am
by ziggy1621
Pimptastic wrote:

Code: Select all

UPDATE `table` SET `field1` = 'blah', `field2` = 'blah', `field3` = 'blah' WHERE `id` = '1-7'
thanks for the response. sorry, let me better clarify... I want to update field 'category1' to equal '2a' for id '1-7'. this is what i have, but only alters where id=1

Code: Select all

UPDATE `listings` SET `category1` = '2a' WHERE `id` = '32-51';
thanks

Posted: Mon Aug 07, 2006 9:28 am
by JayBird
off the top of my head

Code: Select all

UPDATE `listings` SET `category1` = '2a' WHERE `id` => 1 AND `id` <= 7
or

Code: Select all

UPDATE `listings` SET `category1` = '2a' WHERE `id` BETWEEN 1 AND 7
or

Code: Select all

UPDATE `listings` SET `category1` = '2a' WHERE `id` IN(1, 2 ,3, 4, 5, 6, 7)

Posted: Mon Aug 07, 2006 9:37 am
by ziggy1621
the second works beautifully... thanks