Web Analytics Made Easy -
StatCounter Adding field to existing table - CodingForum

Announcement

Collapse
No announcement yet.

Adding field to existing table

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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; Sep 3, 2011, 03:40 PM.

  • #2
    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.

    Comment


    • #3
      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

      Comment


      • #4
        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.

        Comment


        • #5
          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.

          Comment


          • #6
            Will do. Thank you very much.

            Comment

            Working...
            X