Jump to content

Recommended Posts

Hello.  This is probably pretty easy, but I'm not sure how to do this because I've only used phpMyAdmin and not hand-coded SQL...

 

I just used phpMyAdmin to add a new column/header to a table that has about 150 different records in it.  Right now, the column is obviously blank for each entry.  Is there a way to bulk-fill-in all the fields in my new column to read "2"?  The only way I know how to do it is to manually update each record by selecting it in phpMyAdmin and then editing it...

 

Thanks!...

 

Link to comment
https://forums.phpfreaks.com/topic/70496-solved-easy-sql-update-question/
Share on other sites

Hi,

 

The SQL query you'll need is

UPDATE mytable SET new_field = '2'

 

where mytable and new_field are the names of your table and column respectively.

 

You can run this in phpMyAdmin by clicking the SQL tab for the selected table. Just type the statement above into the text box and hit go. PhpMyAdmin will then run the query and notify you of how many rows were updated.

 

An easier way to do this in future is to set the default value to 2 when you add a new column to your table.

 

Cheers,

Darren.

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.