SQL Query help required - Postet den (1466 Views)
Average Member
Webbo
Innlegg: 982
982
I want to update a range of products within a MySql database using phpMyAdmin

The SQL Query I'm using is:

UPDATE `products` SET `manufacturers_id` = '1' WHERE `products`.`products_id` = 3 LIMIT 1;


What I'd like to do is place a range in place of '3' in 'products.products_id'=

So that I can update a range of ID's at once instead of doing them all individually. Can someone please show me how?
Thanks
   
 Sidestørrelse 
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
One solution is to use the IN operator and provide a comma separated list of the record you wish to update:
Code:
UPDATE TABLE SET FIELD1='value' WHERE FIELD2 IN (comma,separated,list,of,values)
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Postet den
Average Member
Webbo
Innlegg: 982
982
Thanks Shaggy, worked a treat :)
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
You're welcome, Webbo smile
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
 
Du må legge inn en melding