-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
  • 704,970
  • 168
  • 1,303
  • 1,425
codepoetly
  • 17
  • 5
  • 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. – a_horse_with_no_name 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 – a_horse_with_no_name 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

0

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
  • 101,766
  • 154
  • 423
  • 727
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
  • 457
  • 4
  • 16
-1

You can use UNION or UNION ALL

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