Can anyone tell me what is wrong with my Query?
I have two tables event and customer, I want to select customer id from customer table and insert it in the customer_id Column in the event table. this is only where the login id in the customers table is the same as the logged in user id
$insEvent_sql = "INSERT INTO event(customer_id, videography_package, event_type, event_shortdesc, event_vanue, event_start)
VALUES(customer-id,'".$safe_videography_package."', '".$safe_event_type."', '".$safe_event_shortdesc."','".$safe_event_vanue."', '".$event_date."') SELECT customer_id FROM 'customer' WHERE login_id = ".$_SESSION['SESS_LOGIN_ID'].";";
You cannot
INSERTa row followed by aSELECT. A work around is to add your row to theSELECT:Using sample data:
Will produce:
INSERT INTO event (customer_id, videography_package, event_type, event_shortdesc, event_vanue, event_start) SELECT 'customer-id' AS customer_id, 'package1' AS videography_package, 'type1' AS event_type, 'short description' AS event_shortdesc, 'some venu' AS event_venu, '2012-05-05' AS event_start UNION ALL SELECT customer_id, NULL, NULL, NULL, NULL, NULL FROM customer WHERE login_id = 1