V
V
Vladimir Polishchuk2012-08-08 02:19:12
MySQL
Vladimir Polishchuk, 2012-08-08 02:19:12

Multiple data update?

Good day. I've been banging my head against a seemingly small problem for about an hour now.
You need to update the data with one query in one table.
Or to simplify it:

UPDATE table SET `field`=0 WHERE `id`=1 or `id`=4 or `id`=14 ...

Tried as follows
UPDATE table SET `field`=0 WHERE `id` IN(1,4,14...);

In either case, only one entry is updated.
I hope I explained clearly...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Beresnev, 2012-08-08
@sectus

1. The first request is not completely written, maybe there is limit 1?
2. Maybe you have only one entry from the entire list of IDs?
Well, I would like to note that the result of UPDATE is the number of changed records. If the value of `field` for all entries from the list before the request is 0, then the result is 0 changed entries. Accordingly, if only one record has 1, then the result is 1 modified record.

I
Iliapan, 2012-08-08
@Iliapan

Well, it works for me:
update tblx set x=0, y=0, z=0
resets to zero for everyone. Maybe you have somewhere Limit wormed its way?

V
Vladimir Polishchuk, 2012-08-08
@NorthDakota

Thanks!!! One bug found! or instead of ,
`id`=1 or `id`=4 or `id`=14…
Hmm… you need to go to bed, otherwise you will have to rewrite everything tomorrow.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question