Solved

transferring old records to new table, but calculating (incrementing) lead ordinals per lead id

Posted on 2012-03-27
2
310 Views
Last Modified: 2012-03-27
hi.
i am not sure if this can be done through a single mysql query, but it was attempted as follows:
// update test transactions table
$sql10 = "INSERT INTO 
			dwtphovu_8347379386_test.8_transactions 
			(
				bigint_TransactionID,
				text_TransactionEvent,
				bigint_SupplierID,
				bigint_LeadID,
				bigint_TransactionAmount,
				bigint_TransactionBalance,
				timestamp_TransactionEvent,
				smallint_LeadOrdinal
			) 
		SELECT 
			PTR.bigint_TransactionID,
			PTR.text_TransactionEvent,
			PTR.bigint_SupplierID,
			PTR.bigint_LeadID,
			PTR.bigint_TransactionAmount,
			PTR.bigint_TransactionBalance,
			PTR.timestamp_TransactionEvent, 
			#insert integers counting from 0 here, per lead id.
		FROM 
			dwtphovu_8347379386_prod.8_transactions PTR;";
$result10 = mysql_query_errors($sql10, $conn , __FILE__ , __LINE__ , true );

Open in new window

if this can be done only via php/mysql combined - how would this be achieved?
0
Comment
Question by:intellisource
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Accepted Solution

by:
intellisource earned 0 total points
ID: 37772343
i'm wondering now, wether it would help to select a count with the insert of each record from the old table - for example:
// update test transactions table
$sql10 = "INSERT INTO 
			dwtphovu_8347379386_test.8_transactions 
			(
				bigint_TransactionID,
				text_TransactionEvent,
				bigint_SupplierID,
				bigint_LeadID,
				bigint_TransactionAmount,
				bigint_TransactionBalance,
				timestamp_TransactionEvent,
				smallint_LeadOrdinal
			) 
		SELECT 
			PTR.bigint_TransactionID,
			PTR.text_TransactionEvent,
			PTR.bigint_SupplierID,
			PTR.bigint_LeadID,
			PTR.bigint_TransactionAmount,
			PTR.bigint_TransactionBalance,
			PTR.timestamp_TransactionEvent, 
			(
				SELECT 
					COUNT(TT.smallint_LeadOrdinal) AS smallint_LeadOrdinal
				FROM 
					dwtphovu_8347379386_test.8_transactions TT 
				WHERE 
					TT.bigint_LeadID = PTR.bigint_LeadID
			)
		FROM 
			dwtphovu_8347379386_prod.8_transactions PTR;";
$result10 = mysql_query_errors($sql10, $conn , __FILE__ , __LINE__ , true );

Open in new window

0
 

Author Closing Comment

by:intellisource
ID: 37772939
and it seems to work beautifully ;)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

734 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