当我用
<span class="x">$sql = "INSERT INTO MSG_TEST(HOUSE_ID,HOUSE_TYPE,PV,UV,CITY_ID,DATELINE) VALUES(13044064,5,6,5,2600,20130227);"; </span>
<code class="language-sql"><span class="err">$</span><span class="k">sql</span> <span class="o">=</span> <span class="ss">"INSERT INTO MSG_TEST(HOUSE_ID,HOUSE_TYPE,PV,UV,CITY_ID,DATELINE) </span> <span class="ss">VALUES</span> <span class="ss">(13044064,5,6,5,2600,20130227),</span> <span class="ss">(1425578,8,6,5,2500,20130227),</span> <span class="ss">(18705325,1,3,3,801,20130227)"</span><span class="p">;</span> <span class="err">看看</span> </code>
<code class="language-text">回答: 第一,mysql_query函数不允许一次执行多条SQL语句的,还有一个函数好像是 mysql_query_multi (),你查找下函数库或手册; 第二,从你提供的SQL语句看,为了执行性能的高效,写成: INSERT INTO MSG_TEST(HOUSE_ID,HOUSE_TYPE,PV,UV,CITY_ID,DATELINE) VALUES(13044064,5,6,5,2600,20130227),(1425578,8,6,5,2500,20130227)....; </code>
mysql_query
(PHP 4, PHP 5)
mysql_query — 发送一条 MySQL 查询
说明
resource mysql_query
( string $query
[, resource $link_identifier
] )
mysql_query()
向与指定的连接标识符关联的服务器中的当前活动数据库发送一条查询。如果没有指定
link_identifier,则使用上一个打开的连接。如果没有打开的连接,本函数会尝试无参数调用
mysql_connect()
函数来建立一个连接并使用之。查询结果会被缓存。
Note:
查询字符串不应以分号结束。