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

Posts: 1,509
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
My Domains & Sites For Sale by Owner
colbyt is online now
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 11-23-2009, 07:02 PM Re: myphpadmin query update dates
wayfarer07's Avatar
I like pie

Posts: 3,357
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.
__________________
Wayfarer | jQuery Tooltip | Mapbox: the jQuery Map
Latest Project: Houston Movers
If Google is the Coca-Cola of Web search, Bing is RC Cola

Last edited by wayfarer07; 11-23-2009 at 07:03 PM..
wayfarer07 is online now
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,509
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
My Domains & Sites For Sale by Owner
colbyt is online now
Reply With Quote
View Public Profile
 
Old 11-23-2009, 09:48 PM Re: myphpadmin query update dates
wayfarer07's Avatar
I like pie

Posts: 3,357
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); 

__________________
Wayfarer | jQuery Tooltip | Mapbox: the jQuery Map
Latest Project: Houston Movers
If Google is the Coca-Cola of Web search, Bing is RC Cola
wayfarer07 is online now
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,509
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
My Domains & Sites For Sale by Owner
colbyt is online now
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 0.10282 seconds with 13 queries