Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
myphpadmin query update dates
Old 11-23-2009, 10:48 AM myphpadmin query update dates
Defies a Status

Posts: 1,606
Trades: 0
I have a database with several thousand rows where I want to update the date field.

I tested the following query on one row:
PHP Code:
UPDATE `database`.`tablenameSET `date` = '2009-10-11' WHERE `date` = '0000-00-00'  LIMIT 1 
It worked fine.

Now my question is can I change just the limit on that statement and sequence though the database using different update dates until all the '0000-00-00' entries are replaced?

I really don't want them all to be the same and I don't really care which ones become newer or older as long as there is a range of dates.

I am doing this on localhost so server load is not a consideration.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-23-2009, 07:02 PM Re: myphpadmin query update dates
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
why not just write a simple script to do it for you?
PHP Code:
$date '2009-10-11';
$result $mysql->query('select date from tablename where date="0000-00-00"');
$timestamp strtotime($date);
while(
$result->num_rows) {
    
$mysql->query('UPDATE `database`.`tablename` SET `date` = "'.$date.'" WHERE `date` = '0000-00-00'  LIMIT 1');
    
$date date('Y-m-d',$timestamp);
    
$timestamp strtotime('-1 day',$timestamp);
    
$result->free();
    
$result $mysql->query('select date from tablename where date="0000-00-00"');

Untested, but something like that should work handily.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.

Last edited by wayfarer07; 11-23-2009 at 07:03 PM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 11-23-2009, 08:49 PM Re: myphpadmin query update dates
Defies a Status

Posts: 1,606
Trades: 0
I would and I could but I don't want them all to be the same. I want a more natural look to the dates.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 11-23-2009, 09:48 PM Re: myphpadmin query update dates
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Make it skip back randomly between 1-5 days each time.
PHP Code:
$amount rand(1,5);
$timestamp strtotime('-'.$amount.' day',$timestamp); 

__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 12-04-2009, 08:01 PM Re: myphpadmin query update dates
Defies a Status

Posts: 1,606
Trades: 0
For the benifit of anyone who discovers this thread in the future and wants to know how to do using phpMyAdmin, (yes I made a typo in the title), all you have to do is change the limit to whatever number of rows you want to update at one time.

If you have the show this query after completion box checked you will come back to the same page when it is complete. You can then repeat it on the same number of rows or simply change the date and go again.

It just isn't all that hard to do.

You really don't need a backend for a scipted site if you take the time to learn all the tools available in phpMyAdmin.


__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to myphpadmin query update dates
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.23179 seconds with 12 queries