您不能INSERT
在一行后跟一个SELECT
. 一种解决方法是将您的行添加到SELECT
:
$insEvent_sql = "INSERT INTO event
(customer_id,
videography_package,
event_type,
event_shortdesc,
event_vanue,
event_start)
SELECT 'customer-id' AS customer_id,
'" . $safe_videography_package . "' AS videography_package,
'" . $safe_event_type . "' AS event_type,
'" . $safe_event_shortdesc . "' AS event_shortdesc,
'" . $safe_event_vanue . "' AS event_venu,
'" . $event_date . "' AS event_start
UNION ALL
SELECT customer_id, NULL, NULL, NULL, NULL, NULL
FROM customer
WHERE login_id = " . $_SESSION['SESS_LOGIN_ID'];
使用样本数据:
$safe_videography_package = 'package1';
$safe_event_type = 'type1';
$safe_event_shortdesc = '简短描述';
$safe_event_vanue = '某个地方';
$event_date = '2012-05-05';
$_SESSION['SESS_LOGIN_ID'] = 1;
将产生:
插入事件
(客户ID,
videography_package,
事件类型,
event_shortdesc,
event_vanue,
事件开始)
选择“客户 ID”作为客户 ID,
'package1' AS videography_package,
'type1' 作为 event_type,
'简短描述' AS event_shortdesc,
'some venu' AS event_venu,
'2012-05-05' 作为 event_start
联合所有
选择客户 ID,空,空,空,空,空
来自客户
在哪里 login_id = 1