0

Dear all,

I have a table in mysql and i want to insert records into the table without using "FOR" or "WHILE" loop..Can this be done??

Thanks in advance..

Jino.

4
Contributors
8
Replies
9
Views
9 Years
Discussion Span
Last Post by indraginanjar
0

What do you mean by without using for or while loop ? What's the problem in inserting a record directly ? ie., insert into tablename (col1,col2) values ('val1','val2')

0

not that i want to insert More than 100 records into my database with a single query.... I need this for making the things fast..

Is that possible??

Thanks

0

If you know the values, you can do something like this.

insert into table (col1) values (val1),(val2),(val3)

This will insert 3 records to the table.

0

nave it is ok when we enter the records manually and we know the no. of records

Here it is not the case... I have an array having the value of several records that i it got as a result of a query..

I now want to insert these records into an another table without using the while or for loop...
Hope u get me..

Thanks in advance..
Jino.

0

I am trying to do that without a loop...

cos that will make things done faster..

Pls get back to me if u get any idea about this..

Once again thx
Jino.

0

I think you can get it done relatively easy by using INSERT ... SELECT.
This is the example found in MySQL Reference Manual:

INSERT INTO tbl_temp2 (fld_id)
  SELECT tbl_temp1.fld_order_id
  FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.