Jump to content

How to Update A database


Go to solution Solved by Ch0cu3r,

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

Edited by IlaminiAyebatonyeDagogo
Link to comment
Share on other sites

  • Solution

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
Edited by Ch0cu3r
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.