record update question

Codes here !

Moderators: egami, macek, gesf

Post Reply
billygoatkaraoke
New php-forum User
New php-forum User
Posts: 91
Joined: Sat Aug 13, 2011 7:20 pm

Sun Sep 23, 2012 9:08 pm

Gidday

I have an array of numbers which a php page receives via $_POST - the numbers represent mysql row ids.

I will be incrementing a count column for each of the rows in the array.

Am I able to do this with one query, or because they are separate rows, will I need to do it with more than one?

I tested some hard coded data with this:

Code: Select all

UPDATE table
SET col=col+1
WHERE id in (1,2,3)
which doesn't work.

Code: Select all

UPDATE table
SET col=col+1
WHERE id =1
successfully updates row one, and

Code: Select all

UPDATE table
SET col=9
WHERE id in (1,2,3)
successfully updates rows 1,2 and 3 to 9


Thanks guys.

Post Reply