Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts

    Adding field to existing table

    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
    Code:
    ("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
    Last edited by Buffmin; 09-03-2011 at 07:40 PM.

  • #2
    New Coder
    Join Date
    Aug 2011
    Posts
    51
    Thanks
    6
    Thanked 12 Times in 12 Posts
    PHP Code:
    ALTER TABLE  `subsADD  `descVARCHAR(60NOT 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.

  • Users who have thanked ASTP001 for this post:

    Buffmin (09-03-2011)

  • #3
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    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

  • #4
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    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.
    Code:
    ("update table 'subs' (DESC) values (ham,salami,cap) where 'NAME' = 'Assorted' ")
    Thanks, Buffmin.

  • #5
    New Coder
    Join Date
    Aug 2011
    Posts
    51
    Thanks
    6
    Thanked 12 Times in 12 Posts
    Try:
    Code:
    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.

  • Users who have thanked ASTP001 for this post:

    Buffmin (09-03-2011)

  • #6
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    Will do. Thank you very much.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •