Adding attributes in a query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jkwok
    New Member
    • Feb 2008
    • 32

    Adding attributes in a query

    Hi,

    I have a table that needs extra attributes added to it after a certain amount of processing has been completed.

    For example Table A has two fields x and y.

    A
    x y

    And now, I need to add a new attribute z. Is this possible using a query? I need to add this attribute and fill in the same value for every record. I was thinking an Update query would work but I've had no success so far.

    Thanks,
    Jason
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Here's an example of how to add a new column to a table through SQL.

    [code=sql]
    ALTER TABLE myTable ADD COLUMN myField TEXT (255)
    [/code]

    This will create a new field called "myField" in table "myTable" that is of the type text and 255 characters in length.

    Once this field is created you could run an update query to fill them all in with the same value.

    [code=sql]
    UPDATE myTable
    SET myField = 'Test'
    [/code]

    Hope this helps.
    Jking

    Comment

    • jkwok
      New Member
      • Feb 2008
      • 32

      #3
      Hey Jking,

      This is great actually, I think this will help me out quite a bit!

      Thanks,
      Jason

      Comment

      Working...