Solved

resolving an error inserting multiple records into one database.table from a multitable select accross databases

Posted on 2012-03-27
1
525 Views
Last Modified: 2012-03-27
i need to insert into table test via mysql in a php document, a built select from various tables in the table production. below is the output - the first element of the array is the sql query, and the second element is the sql error returned.
Array
(
    [0] => INSERT INTO 
			dwtphovu_8347379386_test.6_serviceleads TSL 
			(
				TSL.bigint_LeadID,
				TSL.text_Consumer,
				TSL.text_LeadAttributes,
				TSL.timestamp_ExpectedBy,
				TSL.text_LeadMessage,
				TSL.bigint_ServiceID,
				TSL.bigint_SupplierID,
				TSL.bigint_RegionID,
				TSL.tinyint_LeadSent,
				TSL.timestamp_LeadCreated,
				TSL.text_Duplicates
			) 
		SELECT 
			bigint_LeadID,
			text_Consumer,
			text_LeadAttributes,
			timestamp_ExpectedBy,
			text_LeadMessage,
			bigint_ServiceID,
			bigint_SupplierID,
			(
				SELECT 
					TR.bigint_RegionID 
				FROM 
					dwtphovu_8347379386_test.1_regions TR,
					dwtphovu_8347379386_prod.1_regions PR 
				WHERE 
					CONCAT("%",UPPER(PR.text_RegionDescription),"%") LIKE CONCAT("%",UPPER(TR.text_RegionDescription),"%") AND 
					PR.bigint_RegionID = PSL.bigint_RegionID
			) AS bigint_RegionID,
			tinyint_LeadSent,
			timestamp_LeadCreated,
			text_LeadSubject 
		FROM 
			dwtphovu_8347379386_prod.6_serviceleads PSL;

    [1] => ERROR #1064: 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 'TSL 
			(
				TSL.bigint_LeadID,
				TSL.text_Consumer,
				TSL.text_LeadAttribu' at line 2 in /home/dwtphovu/public_html/intellisource.co.za/test_8347379386/db_synchronizer.php on Line 57

)

Open in new window

what does this mean in this instance, and how do i resolve it ASAP?
0
Comment
Question by:intellisource
1 Comment
 

Accepted Solution

by:
intellisource earned 0 total points
ID: 37771727
nevermind - INSERT statements can only insert into one table at a time, thus no aliases are allowed. ;) removed the aliases and the sql query runs successfully! XD
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to remove numeric and alpha from an alphanumeric field? 5 70
xpath sql query 2008 8 42
Whether to use true/false, yes/no or 0/1 11 51
Amazon Redshift 2 24
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now