Click to See Complete Forum and Search --> : MySQL 4 query assistance


CG Susan
January 5th, 2007, 10:05 AM
Hi.

I want to change the parameter of one field in my products table. The product's owner is currently listed as "master," and I want to change it to "Susan." I'm not sure what type of query I should use: SELECT, ALTER TABLE, CHANGE....?

I've come up with this skeleton:

SELECT ,master, from product CHANGE to ,Susan,

Would something like that work? I don't think my syntax is correct and this is too important a table for me to mess up.

Thanks!

hspc
January 5th, 2007, 11:09 AM
if you just want to change the name of the resulting column for the current query only (the change will not be permanent)
SELECT master as Susan from product
if you want to change the name of the column permanently you'll need to alter the table:
alter table product change master suzan same_column_definition_for_master
you can know the same_column_definition_for_masterusing this query:
show create table product
you can send the result of the above query (show create...) so I can write the complete alter query for you.
you can (and better) use a tool like phpmyadmin (web based) or MySQL Administrator which is free and good

CG Susan
January 5th, 2007, 12:45 PM
Okay. Let me see if I can do this for you.

The table name is _products, the column is provider, and each cell in that column is named master. I want to change master to Susan.

Here is the results of the SELECT query you had me perform in phpadmin:

SELECT provider AS Susan
FROM `_products`
WHERE 1
LIMIT 0 , 30

hspc
January 5th, 2007, 12:53 PM
Ok
the situation looks clearer
you want to updated the (values) of the column provider in the _products table from 'master' to 'suzan'


at first : take a backup of the table (easy using phpmyadmin)
then run this query:

update _products Set provider = 'suzan' where provider = 'master'

now all records with provider = master will change to suzan.
tell me if it works fine or if you find any problems, don't forget to take a backup before running queries that change a lot of records.

CG Susan
January 5th, 2007, 01:25 PM
The query worked perfectly. Thank you very much!!!