How to use SET to Update a Pre-exiting Table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cleo Millet
    New Member
    • Oct 2011
    • 7

    How to use SET to Update a Pre-exiting Table

    I'm still fairly new to MySQL and I've been given a task by my lecturer that I just can't make work. She wants us to use SET to add a row to a table instead of the regular VALUE method. Here's my code and the error I received:

    Code:
    mysql> INSERT INTO Instructors
    -> SET FacId = 96
    -> SET FirstName = 'Chris'
    -> SET LastName = 'Explorer'
    -> SET HomePhone = '555-1492';
    
    ERROR 1064 (42000): 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 'SET FirstName = 'Chris' SET LastName = 'Explorer' SET HomePhone = '555-1492'' at line 3
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    Its fairly a wrong Insert statement,

    if it is insert statement, then the simplest example is
    Code:
    INSERT INTO tablename(column1, column2,...,columnn) Values(value1,value2,...,valuen);
    If it is update statement the instruction should be
    Code:
    UPDATE tablename set Column1=value1,..., columnn=valuen [WHERE condition] [limit value_of_limit]
    please read the manual to understand instruction in a brief way

    Comment

    Working...