Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...The enviroment is simple, natural and efficient. The members are competent, educated and professionals..."

Geography

Where in the world do Tek-Tips members come from?

Error 2013 on Insert on a junction table

demosoc (TechnicalUser)
10 Aug 12 11:56


Hello All,

I'm new to Mysql and am having some trouble. I'm trying to insert into a junction table, "action_x_recipient", and I'm getting a 2013 error code.

When I run the query w/o the insert, it runs fine.

Basically we get a big data dump (over 8 million rows) which I need to move into the correct tables before dropping the table,"SP". I've already added all distinct recipients (based on unique email) to the "Recipient" table and all unique actions to the "Action" table. There are more tables and junction tables, of course. I haven't had this problem with those tables, however there is more data considered in this situation.

Here are the tables in the query (I've removed fields which are irrelevant to this formula. Also please note that the SP.Mailingname_Id is not equal to MailingName.Id, rather it is represented by MailingName.SPMailing_Id):

Action_x_Recipient
'A_x_R_Id', 'int(11)', NULL, 'NO', 'PRI', NULL, 'auto_increment', 'select,insert,update,references', ''
'Action_Id', 'int(11)', NULL, 'YES', 'MUL', NULL, '', 'select,insert,update,references', ''
'Recipient_Id', 'int(11)', NULL, 'YES', 'MUL', NULL, '', 'select,insert,update,references', ''


Action
'Action_Id', 'int(11)', NULL, 'NO', 'PRI', NULL, 'auto_increment', 'select,insert,update,references', ''
'MailingName_Id', 'int(11)', NULL, 'YES', 'MUL', NULL, '', 'select,insert,update,references', ''

Recipient
'Recipient_Id', 'int(11)', NULL, 'NO', 'PRI', NULL, 'auto_increment', 'select,insert,update,references', ''
'Email', 'varchar(45)', 'latin1_swedish_ci', 'NO', 'UNI', NULL, '', 'select,insert,update,references', ''


MailingName
'MailingName_Id', 'int(11)', NULL, 'NO', 'PRI', NULL, 'auto_increment', 'select,insert,update,references', ''
'SPMailing_Id', 'int(11)', NULL, 'YES', 'UNI', NULL, '', 'select,insert,update,references', ''

SP
'SP_Id', 'int(11)', NULL, 'NO', 'PRI', NULL, 'auto_increment', 'select,insert,update,references', ''
'Mailing_Id', 'int(11)', NULL, 'YES', 'MUL', NULL, '', 'select,insert,update,references', ''
'SP_Report_Id', 'varchar(45)', 'latin1_swedish_ci', 'YES', 'MUL', NULL, '', 'select,insert,update,references', ''
'Email', 'varchar(145)', 'latin1_swedish_ci', 'YES', 'MUL', NULL, '', 'select,insert,update,references', ''
'Event_Type', 'varchar(45)', 'latin1_swedish_ci', 'YES', '', NULL, '', 'select,insert,update,references', ''


Here is the query:


INSERT IGNORE INTO action_x_recipient (Recipient_Id,Action_Id)

SELECT
recipient.Recipient_Id,
action.Action_Id
from
recipient
join
SP ON recipient.email=SP.email
join
mailingname ON SP.Mailing_Id=mailingname.SPMailing_Id
join
action ON mailingname.MailingName_Id = action.MailingName_Id

WHERE
SP.Event_Type='Sent' AND
(recipient.Recipient_Id,action.Action_Id) NOT IN (SELECT
Recipient_Id, Action_Id
FROM
action_x_recipient );


Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close