[PHP] MySQL: copying entire columns

2001-11-30 Thread Tom Churm

hi,

i've created a mysql table from an excel csv dump and the field-order is
not the way i want it.  could someone possibly give me a hint on how i
can create a copy of an entire column, place it in the position where i
want in my table, and then delete the original column?

i'm using phpMyAdmin and there doesn't appear to be any way to
restructure my table--so i've gotta resort to sql.

mucho gracias,

tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySQL: copying entire columns

2001-11-30 Thread Miles Thompson

Tom

It's a relational database, field column position does not matter. One 
Date's 121 rules, if I remember correctly.

In terms of human readability, it sometimes matters. Check the MySQL 
manual, I think there's an example of this under the ALTER TABLE command.

But really, position doesn't matter, exept to fulfill a human sense of 
tidiness.

Cheers - Miles Thompson

At 01:53 PM 11/30/2001 +0100, Tom Churm wrote:
hi,

i've created a mysql table from an excel csv dump and the field-order is
not the way i want it.  could someone possibly give me a hint on how i
can create a copy of an entire column, place it in the position where i
want in my table, and then delete the original column?

i'm using phpMyAdmin and there doesn't appear to be any way to
restructure my table--so i've gotta resort to sql.

mucho gracias,

tom

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySQL: copying entire columns

2001-11-30 Thread Tom Churm

hi, miles:

i think you helped me hit on something big here.  each time i've been
using INSERT statements in my php code, i've been addressing the field
names in exactly the order they appear in my mysql table.  ie: i've been
using

$sql = Insert into $table_name(Name, Address, Phone)
values('$Name','$Address','$Phone');

where the columns appear in this order.  but i think i finally realized
that this (all in the wrong order) would work as well--if that's what
you mean:

$sql = Insert into $table_name(Address, Phone, Name)
values('$Address','$Phone','$Name');

if this is true, it'll save me a lot of useless time trying to reorder
my tables.

thanks much,

tom

Miles Thompson wrote:
 
 Tom
 
 It's a relational database, field column position does not matter. One
 Date's 121 rules, if I remember correctly.
 
 In terms of human readability, it sometimes matters. Check the MySQL
 manual, I think there's an example of this under the ALTER TABLE command.
 
 But really, position doesn't matter, exept to fulfill a human sense of
 tidiness.
 
 Cheers - Miles Thompson
 
 At 01:53 PM 11/30/2001 +0100, Tom Churm wrote:
 hi,
 
 i've created a mysql table from an excel csv dump and the field-order is
 not the way i want it.  could someone possibly give me a hint on how i
 can create a copy of an entire column, place it in the position where i
 want in my table, and then delete the original column?
 
 i'm using phpMyAdmin and there doesn't appear to be any way to
 restructure my table--so i've gotta resort to sql.
 
 mucho gracias,
 
 tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySQL: copying entire columns

2001-11-30 Thread Andrey Hristov

?php
$which_column = 0; // starting  from 0
$fname = some.csv;
$out_fname = some_new.csv;
$cschar = ,;
$f_cont = file($fname);
foreach ($f_cont as $key =$value){

$tmp = explode($cschar,trim($value));
$tmp[count($tmp)] = $tmp[$which_column];
unset($tmp[$which_column]);
$out_cont[] = implode(,,$tmp);
}
$fd = fopen($out_fname,'w+');
fwrite($fd,implode(\r\n,$out_cont));
fclose($fd);
?

HTH

Regards,
Andrey Hristov



- Original Message - 
From: Tom Churm [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, November 30, 2001 2:53 PM
Subject: [PHP] MySQL: copying entire columns


 hi,
 
 i've created a mysql table from an excel csv dump and the field-order is
 not the way i want it.  could someone possibly give me a hint on how i
 can create a copy of an entire column, place it in the position where i
 want in my table, and then delete the original column?
 
 i'm using phpMyAdmin and there doesn't appear to be any way to
 restructure my table--so i've gotta resort to sql.
 
 mucho gracias,
 
 tom
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]