Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
psychotomus
Forum Contributor
Posts: 487 Joined: Fri Jul 11, 2003 1:59 am
Post
by psychotomus » Mon Aug 14, 2006 4:52 am
I have a table
Code: Select all
mysql_query("CREATE TABLE Sites(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), hits_in INT(6) NOT NULL, hits_out INT(6) NOT NULL, total_in INT(7) NOT NULL, total_out INT(7) NOT NULL, site_name VARCHAR(200), site_url VARCHAR(200), banner_url VARCHAR(200), rating INT(4) NOT NULL, votes INT(4) NOT NULL, approved VARCHAR(1) NOT NULL, approved_by INT(6) NOT NULL, approved_message VARCHAR(250), username VARCHAR(30), comments INT(4) NOT NULL, description BLOB)")or die("Create table Error: ".mysql_error());
After 24 hour I want to reset all hits_in and hits_out to 0. Is this possible with 1 or 2 SQL Commands or do i have to update every entry 1 at a time?
s.dot
Tranquility In Moderation
Posts: 5001 Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana
Post
by s.dot » Mon Aug 14, 2006 5:03 am
Code: Select all
mysql_query("UPDATE `Sites` SET `hits_in` = 0, `hits_out` = 0") or die("Error resetting stats: ".mysql_error());
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
psychotomus
Forum Contributor
Posts: 487 Joined: Fri Jul 11, 2003 1:59 am
Post
by psychotomus » Mon Aug 14, 2006 5:19 am
thanks. didnt know it was like that.
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Mon Aug 14, 2006 4:05 pm
Most people find that little trick out the hard way... by forgetting a where clause when updating a single record
. Learn once, I always say...