...

View Full Version : Adding field to existing table



Buffmin
09-03-2011, 08:36 PM
Hello, quite new here. I am using php (vers 5) and mysql. I have an existing table called subs. It has 3 fields (columns) called MANE, FULL & HALF. I am just trying to add an additional field. I am trying the query
("ALTER TABLE subs ADD DESC ,VARCHAR(60) ") .
Does not work. I've tried about every combination I could think of! Could someone please help me. Thanks Buffmin

PS: The error I get is....
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC ,VARCHAR(60)' at line 1

ASTP001
09-03-2011, 08:58 PM
ALTER TABLE `subs` ADD `desc` VARCHAR(60) NOT NULL ;

try that.

Also, I'm wondering if you know of something called phpMyAdmin. It makes managing your database very easy. it's usually in the control panel of your host.

Buffmin
09-03-2011, 09:06 PM
Thank you so much. You're awesome. Yes, I have used phpMyAdmin to an extent, but the site is actually on a friend's hosting acct, so I don't have access to his main login to use that, so I am kind of stuck accessing the table via mysql (if that made sense to you). Thanks again.I appreciate it. Buffmin

Buffmin
09-03-2011, 09:32 PM
Here is one more for you, if you don't mind (I am just getting comfortable with mysql as you can see, but saving all of my examples for future ref). I am now trying to put a value into the 'DESC' row (description row) where the NAME = Assorted. If you or anyone could help me, I would appreciate it.

("update table 'subs' (DESC) values (ham,salami,cap) where 'NAME' = 'Assorted' ") Thanks, Buffmin.

ASTP001
09-03-2011, 09:49 PM
Try:


UPDATE subs SET desc='ham,salami,cap' WHERE name=assorted


If you go to http://www.w3schools.com/php/php_mysql_intro.asp they have a good tutorial on these things that will answer your questions fairly quickly.

Buffmin
09-03-2011, 09:57 PM
Will do. Thank you very much.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum