Jump to content

How to Update A database


Recommended Posts

how to update a database field considering a specific amount of values.

the code i Know is

this is to update a specific value

UPDATE `users` SET `user_level`=1 WHERE `user_id`=7 

and this is to update a particular field

UPDATE `users` SET `user_level`=1; 

but the code for a range of values in a field using the id as the range say where id=7 to 35, i don't know the code

Link to comment
https://forums.phpfreaks.com/topic/284379-how-to-update-a-database/
Share on other sites

If you want to set the user_level to 1 where user_id is between 7 and 35 then use

UPDATE `users` SET `user_level`=1 WHERE `user_id` >= 7 AND `user_id` <= 35

>= means greater than or equal to

<= means less than or equal to

 

Alternatively you could use

UPDATE `users` SET `user_level`=1 WHERE `user_id` BETWEEN 7 AND 35

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.