473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Easy way to "reset" data in whole columns to default value?

JL
Hi there
I have a database with entries like the following:

Id, Name, Goals_season, Goals_total
----------------------------------------
5, John, 5, 23
6, Mike, 2, 14
7, Joe, 10, 34

Every season we have to reset the "Goals_season" column to the default value
(0), but not the other columns...
What is the easiest way to do this? Should I simply delete the column and
create a new column, or...?
(I hope my question isn't to stupid - it's been a year since I worked with
mysql)
Best regards
JL
Jul 19 '05 #1
15 10265
JL wrote:
Hi there
I have a database with entries like the following:

Id, Name, Goals_season, Goals_total
----------------------------------------
5, John, 5, 23
6, Mike, 2, 14
7, Joe, 10, 34

Every season we have to reset the "Goals_season" column to the default value
(0), but not the other columns...
What is the easiest way to do this? Should I simply delete the column and
create a new column, or...?


update yourtablename set Goals_season=0;
Jul 19 '05 #2
JL wrote:
Hi there
I have a database with entries like the following:

Id, Name, Goals_season, Goals_total
----------------------------------------
5, John, 5, 23
6, Mike, 2, 14
7, Joe, 10, 34

Every season we have to reset the "Goals_season" column to the default value
(0), but not the other columns...
What is the easiest way to do this? Should I simply delete the column and
create a new column, or...?


update yourtablename set Goals_season=0;
Jul 19 '05 #3
JL


update yourtablename set Goals_season=0;


Thanks for your reply.
Is update a good (efficient) way to do it if the table contains 20 columns x
500+ rows... that needs to be updated?
(the table I presented was simplified, it actually contains 20 columns that
needs to be set to 0...)
Cheers
JL
Jul 19 '05 #4
JL


update yourtablename set Goals_season=0;


Thanks for your reply.
Is update a good (efficient) way to do it if the table contains 20 columns x
500+ rows... that needs to be updated?
(the table I presented was simplified, it actually contains 20 columns that
needs to be set to 0...)
Cheers
JL
Jul 19 '05 #5
JL wrote:
update yourtablename set Goals_season=0;

Thanks for your reply.
Is update a good (efficient) way to do it if the table contains 20 columns x
500+ rows... that needs to be updated?


The amount of columns doesn't matter AFAIK.
500 rows is nothing, you don't even need to think about speed with that
row count.

I tested it with 20 column table, with 5000 rows. It took 0.16 seconds
to complite on my old 166MHz Pentium.

mysql> update testtable set a4=0;
Query OK, 5000 rows affected (0.16 sec)
Rows matched: 5000 Changed: 5000 Warnings: 0
Jul 19 '05 #6
JL wrote:
update yourtablename set Goals_season=0;

Thanks for your reply.
Is update a good (efficient) way to do it if the table contains 20 columns x
500+ rows... that needs to be updated?


The amount of columns doesn't matter AFAIK.
500 rows is nothing, you don't even need to think about speed with that
row count.

I tested it with 20 column table, with 5000 rows. It took 0.16 seconds
to complite on my old 166MHz Pentium.

mysql> update testtable set a4=0;
Query OK, 5000 rows affected (0.16 sec)
Rows matched: 5000 Changed: 5000 Warnings: 0
Jul 19 '05 #7
JL wrote:
Hi there
I have a database with entries like the following:

Id, Name, Goals_season, Goals_total
----------------------------------------
5, John, 5, 23
6, Mike, 2, 14
7, Joe, 10, 34

Every season we have to reset the "Goals_season" column to the default value
(0), but not the other columns...
What is the easiest way to do this? Should I simply delete the column and
create a new column, or...?


update yourtablename set Goals_season=0;
Jul 19 '05 #8
JL


update yourtablename set Goals_season=0;


Thanks for your reply.
Is update a good (efficient) way to do it if the table contains 20 columns x
500+ rows... that needs to be updated?
(the table I presented was simplified, it actually contains 20 columns that
needs to be set to 0...)
Cheers
JL
Jul 19 '05 #9
>> Thanks for your reply.
Is update a good (efficient) way to do it if the table contains 20
columns x
500+ rows... that needs to be updated?


The amount of columns doesn't matter AFAIK.
500 rows is nothing, you don't even need to think about speed with that
row count.


yep speed really doesn't matter with that row count.
maybe you know this already, but another thing to mention:
if one column is a timestamp then mysql will automatically update this
column to the current date/time.
if you have multiple timestamp columns then only the first will be updated.
if you want to prevent this set the first timestamp to itself:
UPDATE `yourtablename` SET `Goals_season` = 0, `1_Timestamp_col` =
`1_Timestamp_col`;

i lost millions of rows because i oversight this in the mysql manual...
chris
Jul 19 '05 #10
>> Thanks for your reply.
Is update a good (efficient) way to do it if the table contains 20
columns x
500+ rows... that needs to be updated?


The amount of columns doesn't matter AFAIK.
500 rows is nothing, you don't even need to think about speed with that
row count.


yep speed really doesn't matter with that row count.
maybe you know this already, but another thing to mention:
if one column is a timestamp then mysql will automatically update this
column to the current date/time.
if you have multiple timestamp columns then only the first will be updated.
if you want to prevent this set the first timestamp to itself:
UPDATE `yourtablename` SET `Goals_season` = 0, `1_Timestamp_col` =
`1_Timestamp_col`;

i lost millions of rows because i oversight this in the mysql manual...
chris
Jul 19 '05 #11
JL wrote:
update yourtablename set Goals_season=0;

Thanks for your reply.
Is update a good (efficient) way to do it if the table contains 20 columns x
500+ rows... that needs to be updated?


The amount of columns doesn't matter AFAIK.
500 rows is nothing, you don't even need to think about speed with that
row count.

I tested it with 20 column table, with 5000 rows. It took 0.16 seconds
to complite on my old 166MHz Pentium.

mysql> update testtable set a4=0;
Query OK, 5000 rows affected (0.16 sec)
Rows matched: 5000 Changed: 5000 Warnings: 0
Jul 19 '05 #12
JL
Thank you for your help
Have a nice weekend.
- JL
Jul 19 '05 #13
JL
Thank you for your help
Have a nice weekend.
- JL
Jul 19 '05 #14
>> Thanks for your reply.
Is update a good (efficient) way to do it if the table contains 20
columns x
500+ rows... that needs to be updated?


The amount of columns doesn't matter AFAIK.
500 rows is nothing, you don't even need to think about speed with that
row count.


yep speed really doesn't matter with that row count.
maybe you know this already, but another thing to mention:
if one column is a timestamp then mysql will automatically update this
column to the current date/time.
if you have multiple timestamp columns then only the first will be updated.
if you want to prevent this set the first timestamp to itself:
UPDATE `yourtablename` SET `Goals_season` = 0, `1_Timestamp_col` =
`1_Timestamp_col`;

i lost millions of rows because i oversight this in the mysql manual...
chris
Jul 19 '05 #15
JL
Thank you for your help
Have a nice weekend.
- JL
Jul 19 '05 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: JL | last post by:
Hi there I have a database with entries like the following: Id, Name, Goals_season, Goals_total ---------------------------------------- 5, John, 5, 23 6, Mike, 2, 14 7, Joe, 10, 34 Every...
1
by: PeteCresswell | last post by:
I'm working on a new report in an MS Access DB. The first anomaly was a message "This action will reset the current code in break mode." when the report was run. Seems TB something about my...
0
by: hoenes1 | last post by:
Hi all, I'm trying to send files to a client following the instructions of http://support.microsoft.com/?id=812406 Everything works fine, but if files are large and/or if the bandwidth is...
5
by: Alex Maghen | last post by:
Hi. Is there a way to make a call in ASP.NET that will effectively do exactly the same thing is when you "touch"/change the web.config file? In other words, I want to be able to programmatically...
53
by: Sanders Kaufman | last post by:
I'm having a BLAST writing this app as OOP as PHP allows. It's one thing to discuss the dance, but it's a thing of beauty to see the performance. I'm noticing that the constructor is a "reset"...
12
Frinavale
by: Frinavale | last post by:
I think I'm trying to do something impossible. I have a <div> element with a overflow style set to "scroll". In other words my <div> element allows the user to scroll the content within it. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.