mySQL date question...
 
Notifications
Clear all

mySQL date question (not related to efic)

2 Posts
2 Users
0 Reactions
2,042 Views
(@mickinell)
Posts: 62
Trusted Member
Topic starter
 

random question:

TABLE A has DATETIME 0000-00-00 00:00:00.
TABLE B just uses 0000-00-00.

Is there a way to dump table a into b correctly?  A way to convert the data?


URL to your eFiction:  http://www.mickiclark.com/efiction33
Version of eFiction:  3.3.1
Have you bridged eFiction, if so with what?:  SMF
Version of PHP:
Version of MySQL: MySQL 4.1.14

 
Posted : 27/03/2008 3:13 pm
(@tammy)
Posts: 2577
Member Moderator
 

Natively in mySQL?  Don't know. Probably, but I couldn't tell you how off the top of my head. You could certainly create a php script to convert it.  Explode the table A data on the space and then insert the first item in the array.  Pseudo-code below:


$tableA = dbquery("SELECT FIELD FROM TABLEA");
while($tA = dbassoc($tableA)) {
    $field = explode(" ", $tA['FIELD']);
    dbquery("INSERT INTO TABLEB(`field`) VALUES('".$field[0]."'");
}

 
Posted : 28/03/2008 3:13 pm
Share: