You are here: insert multi rows with a single mysql function call? « PHP Programming Language « IT news, forums, messages
insert multi rows with a single mysql function call?

Posted by newbie on 07/21/07 03:46

Dear folks,
pardon me if this is a stupid question.

For this table
---------------------------------------
| id | foo | bar |
--------------------------------------

I understand that we can insert a row to the table per call, like this
sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1',
'$string_2')";
mysql_query($sql_query, $db_handle);

if I want to insert multi rows(the following example inserts two rows)
at the same time, the following example works, but can I merge this
two insertion into a single mysql operation (to achieve efficiency)?

sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1',
'$string_2')";
mysql_query($sql_query, $db_handle);
sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1',
'$string_2')";
mysql_query($sql_query, $db_handle);

Thanks,

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация