|
-
January 5th, 2007, 11:05 AM
#1
MySQL 4 query assistance
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!
Susan Ross Moore
Assistant Editor
Jupitermedia.com
Serving www.codeguru.com and www.developer.com.
-
January 5th, 2007, 12:09 PM
#2
Re: MySQL 4 query assistance
if you just want to change the name of the resulting column for the current query only (the change will not be permanent)
Code:
SELECT master as Susan from product
if you want to change the name of the column permanently you'll need to alter the table:
Code:
alter table product change master suzan same_column_definition_for_master
you can know the same_column_definition_for_masterusing this query:
Code:
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
-
January 5th, 2007, 01:45 PM
#3
Re: MySQL 4 query assistance
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
Susan Ross Moore
Assistant Editor
Jupitermedia.com
Serving www.codeguru.com and www.developer.com.
-
January 5th, 2007, 01:53 PM
#4
Re: MySQL 4 query assistance
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:
Code:
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.
-
January 5th, 2007, 02:25 PM
#5
Re: MySQL 4 query assistance
The query worked perfectly. Thank you very much!!!
Susan Ross Moore
Assistant Editor
Jupitermedia.com
Serving www.codeguru.com and www.developer.com.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|