By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,188 Members | 844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,188 IT Pros & Developers. It's quick & easy.

How to use SET to Update a Pre-exiting Table

Cleo Millet
P: 7
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:

Expand|Select|Wrap|Line Numbers
  1. mysql> INSERT INTO Instructors
  2. -> SET FacId = 96
  3. -> SET FirstName = 'Chris'
  4. -> SET LastName = 'Explorer'
  5. -> SET HomePhone = '555-1492';
  6.  
  7. 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
Oct 4 '11 #1
Share this Question
Share on Google+
1 Reply


100+
P: 1,059
Its fairly a wrong Insert statement,

if it is insert statement, then the simplest example is
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tablename(column1, column2,...,columnn) Values(value1,value2,...,valuen);
  2.  
If it is update statement the instruction should be
Expand|Select|Wrap|Line Numbers
  1. UPDATE tablename set Column1=value1,..., columnn=valuen [WHERE condition] [limit value_of_limit]
  2.  
please read the manual to understand instruction in a brief way
Oct 17 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.