-1
insert into fees (name, salary) 
values ('john', 155), ('katy', 300); 

This sometimes throws an error

missing right parenthesis

sometimes it is

SQL statement not properly ended

if I use double quotes for name entries... What's the issue?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
codepoetly
  • 17
  • 1
  • 6
  • 2
    Which DBMS are you using? Oracle for one does not support that syntax. And older SQL Server versions did not either. You should always post the **complete** and **exact** error message when asking for help. –  Nov 22 '16 at 07:07
  • What @a_horse_with_no_name said. The statement itself seems fine. Your problem must be lying elsewhere. – Jens Nov 22 '16 at 08:40
  • @Jens: the statement is not "fine" if she/he is using e.g. Oracle –  Nov 22 '16 at 08:42
  • @a_horse_with_no_name that's why I started off with quoting your answer. As long as OP stayed within those constraints he should be fine. – Jens Nov 22 '16 at 08:43

3 Answers3

1

It would probably be easier to have multiple sql statements. For example:

INSERT INTO fees(name, salary) VALUES ('john', 155);
INSERT INTO fees(name, salary) VALUES ('katy', 300);

However, if you want to use the multiple-inserts-in-one-statement, you can have a look at https://stackoverflow.com/a/452882/651174, and do something like this:

INSERT INTO fees(name, salary) VALUES ('john', 155), ('katy', 300);

What are you using to do the SQL insert if you're running into string-formatting issues?

Community
  • 1
  • 1
David542
  • 104,438
  • 178
  • 489
  • 842
0

TRY This

INSERT INTO fees(name, salary) VALUES 
('john', 155),
('katy', 300); 

Go to the below link for further information

Inserting multiple rows in a single SQL query?

Community
  • 1
  • 1
Rohit Gupta
  • 455
  • 4
  • 16
  • 1
    This is exactly the statement in the question which "gives an error" –  Nov 22 '16 at 08:01
-1

You can use UNION or UNION ALL

INSERT INTO fees(name, salary) 
select 'john', 155
union all
select 'katy', 300