PDA

View Full Version : ...More mySQL Questions - How do I...


gengar003
06-17-2003, 11:16 PM
... How do I change the name of a field in a table, say, from "likescheese" to "likesmilk" ?

Gary King
06-17-2003, 11:29 PM
ALTER TABLE tbl_name CHANGE old_field new_field

gengar003
06-17-2003, 11:50 PM
Another question:

in
$keeparray = $DB_site->query("SELECT 'name','catchname','data' FROM tacemonquery WHERE name='$th_old_name'");


I'd reference "name", "catchname" and "data" by

$keeparray['name'] or $keeparray[name], right? Because it's not working, Maybe something's wrong with the query....

Help?

also, this:


$DB_site->query("ALTER TABLE user CHANGE '$keeparray[catchname]', '$th_rong_name'");


Returns an error, PRESUMABLY because the two variables, both of which are set based on the keeparray mentioned above, are assigned no value... That aside, is the syntax right to change user field $keeparray[catchname] to $th_rong_name ?

filburt1
06-17-2003, 11:57 PM
$keeparray['name'], only.

Second question:

$DB_site->query("ALTER TABLE user CHANGE " . $keeparray['catchname'] . " $th_rong_name");

...assuming, of course, that $keeparay['catchname'] and $th_rong_name contain valid column names.

gengar003
06-18-2003, 12:09 AM
Heh, thanx, it works now, It turns out that I needed to remove some quotes, since.......



anyway, it works now.

:)

Once again, filburt saves the daY!