我只想将这些表合并/组合到一个查询中,但它不起作用。实际上有太多的表格和列,但对于这个例子,我只是放了一些。
$insertSQL_sr1 = "INSERT INTO sr1_full (`date`, `total_pending`, `appt_today`, `percent_appt_today`) SELECT `date`, `total_pending`, `appt_today`, `percent_appt_today` FROM `sr1`";
$insertSQL_sr2 = "INSERT INTO sr2_full (`date`, `total_pending`, `appt_today`, `percent_appt_today`) SELECT `date`, `total_pending`, `appt_today`, `percent_appt_today` FROM `sr2`";
$insertSQL_sr3 = "INSERT INTO sr3_full (`date`, `total_pending`, `appt_today`, `percent_appt_today`) SELECT `date`, `total_pending`, `appt_today`, `percent_appt_today` FROM `sr3`";
$insertSQL_full = $insertSQL_sr1.";".$insertSQL_sr2.";".$insertSQL_sr3;
mysql_query($insertSQL_full);
mysql_select_db($database_pods, $pods);
$Result1 = mysql_query($insertSQL_full, $pods) or die(mysql_error());
出现错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO sr2_full (`date`, `total_pending`, `appt_today`, `percent_appt_today' at line 1
我的第二次编辑:
$insertSQL = "INSERT INTO sr1_full (`date`, `total_pending`, `appt_today`, `percent_appt_today`) SELECT `date`, `total_pending`, `appt_today`, `percent_appt_today` FROM `sr1`; INSERT INTO sr2_full (`date`, `total_pending`, `appt_today`, `percent_appt_today`) SELECT `date`, `total_pending`, `appt_today`, `percent_appt_today` FROM `sr2`; INSERT INTO sr3_full (`date`, `total_pending`, `appt_today`, `percent_appt_today`) SELECT `date`, `total_pending`, `appt_today`, `percent_appt_today` FROM `sr3`";
mysql_select_db($database_pods, $pods);
$Result1 = mysql_query($insertSQL, $pods) or die(mysql_error());
出现错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO sr2_full (`date`, `total_pending`, `appt_today`, `percent_appt_today' at line 1