Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I have an incorrect syntax error [duplicate]

Tags:

sql-server

INSERT INTO FoodLog
(Person,Food,ServingSize,Date,Meal)
VALUES
('John','Cheerios',2,'1-APR-2014','Breakfast')
('John','TBoneSteak',1,'2-APR-2014','Lunch')

In this code, the first line of code works just fine, but when I type up the second line of code with the same person name, it doesn't accept it.

This is the error that I receive:

Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'John'.

like image 864
user3533747 Avatar asked Apr 19 '14 02:04

user3533747


2 Answers

For the sake of having an answer rather than a comment. Exactly as @helderdarocha said, "You are missing a comma in between the lines."

INSERT INTO FoodLog (Person,Food,ServingSize,Date,Meal)
VALUES ('John','Cheerios',2,'1-APR-2014','Breakfast')
      ,('John','TBoneSteak',1,'2-APR-2014','Lunch')
like image 126
Karl Kieninger Avatar answered Sep 21 '22 22:09

Karl Kieninger


As @helderdarocha and @Karl Kieninger said you are missing a comma between the tuples or if you still cant resolve the issue, try writing individual entries....I can`t think of anything else possible...

    INSERT INTO FoodLog VALUES ('John','Cheerios',2,'1-APR-2014','Breakfast');
    INSERT INTO FoodLog VALUES ('John','TBoneSteak',1,'2-APR-2014','Lunch');
like image 42
Mudit Avatar answered Sep 20 '22 22:09

Mudit