Reputation:
I have a phpmyadmin database, I have tables with records in them, if i select a bunch of records and then hit edit it give me a printout of all the records, but i want to change ONE field in one column for all the records checked without having to scroll and change EVERY record and then hit "go"
any idea how to do that
we are talking about thousands of records, I need to just change ONE field column from "-3000" to "0"
Tried getting help in #PHPMYADMIN in IRC but everyone was sleeping i think
Upvotes: 2
Views: 10388
Reputation: 629
You don't have a phpMyAdmin database: you have a MySQL database and you use phpMyAdmin as an administrative interface.
This distinction is important because with every relational database you can use SQL to insert/update records in your tables. That is exactly what phpMyAdmin does: under the hood it uses SQL to change the content of your tables.
Using SQL is a trivial thing changing thousands of records with a single statement, for example if the table is called atable
and the column is called acolumn
, you could do an update like this:
UPDATE `atable` SET `acolumn`=-3000 WHERE `acolumn`=0;
phpMyAdmin allows you to execute SQL code directly, but since it looks like this is the first time you try this, I strongly advise to make a backup first.
Upvotes: 5
Reputation: 18123
Without the exact database structure and condition it's a bit hard to answer your question, but I will try anyways.
You say that you have selected a bunch of record, so not all records of that table. You can change one column of all by using this query. I presume you know how to do that in phpmyadmin.
UPDATE table SET column='value' WHERE otherColums='filteritbythis'
If you want to change all the record of the table, you can easily drop the WHERE statement
UPDATE table SET column='value'
Upvotes: 0
Reputation: 5244
phpmyadmin ships with a SQL editor, which you can write SQL queries and run it on the current active database. It would make your task easier.
With the query here below, you can change the column content -3000 to 0.
UPDATE
your_table_to_change
SET
columname = 0
WHERE
columname = -3000;
The above query will update table your_table_to_change
at column columname
to 0 if the column-value is -3000. If you have another conditions to select which rows should be updated, please use AND other_condition
in the WHERE
clause.
Upvotes: 0