0

I'm trying to insert values to a table, but it kept giving me error msg saying the command not properly ended. I checked again and again, I don't see I miss any comma, semicoma, and the table name is correct (I also checked again and again), all column names are correct and in right order too (I checked it again and again too), and the spell of the command is also correct. So what's wrong with my code?

insert into fruits (fid,fname,quantities)
values (1,'apple',3),
   (2,'orange',2),
   (3,'banana',5);
user3390471
  • 87
  • 1
  • 8

2 Answers2

0

As you tagged question as oracle, it don't support that kind of multiple insert query like SQL server and mysql does.
Alternatively you can use insert all as

INSERT ALL INTO mytable (column1, column2, column_n)
    VALUES (expr1, expr2, expr_n) INTO mytable (column1, column2, column_n)
    VALUES (expr1, expr2, expr_n) INTO mytable (column1, column2, column_n)
    VALUES (expr1, expr2, expr_n) SELECT * FROM dual;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
Mesar ali
  • 1,832
  • 2
  • 16
  • 18
0

It is probably simplest to use insert . . . select:

insert into fruits (fid, fname, quantities)
    select 1, 'apple', 3 from dual union all
    select 2, 'orange', 2 from dual union all
    select 3, 'banana', 5 from dual;

Or three separate insert statements.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786