作者cafedelmar ( )
看板PHP
標題Re: [請益] mssql mysql 執行多筆sql問題
時間Thu Dec 30 18:52:14 2010
我用mysql程式去下
insert into table1 xxxxxx ; insert into table2 xxxxxx
同一行會error
但是如果分行下
insert into table1 xxxxxx
;
insert into table2 xxxxxx
這樣是可行的
php內容
$sql=<<< str
insert into table1 xxxxxx
;
insert into table2 xxxxxx
str;
執行之後他會歸成同一行,就error了
要如何解決哩ˊˋ
※ 引述《tkdmaf (皮皮快跑)》之銘言:
: ※ 引述《cafedelmar ( )》之銘言:
: : 原資料庫是mssql
: : 有時同時要insert db時候會這樣下:
: : $sql=<<< str
: : insert into table1 xxxxxx
: : insert into table2 xxxxxx
: : str;
: : $ressql=odbc_exec($odbcDB,$sql);
: : 但是改成mysql就會error
: : 請問mysql是否不能同時下多筆sql勒
: : 煩請賜教
: 如果你能自行組成欄位及資料的話,在table相同的情形下是可以如此使用
: $sql = "INSERT INTO `資料表` (欄位) VALUES (值1),(值2),(值3).....";
: 不過如果資料表不同的話就還是分開來寫。
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.43.104.198
1F:→ MOONRAKER:用多行的 " " 不就得了 12/31 12:49