<div>Hello Manfred,</div><div> </div><div>Did the table named <em>task</em> have child tables? The records whose task_id was 1 were in child tables rather than <em>task?</em></div><div> </div><div>Could you please try following query?</div><div> </div><div><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in">INSERT INTO task_history (task_id, user_id, task_date)</p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in">SELECT task_id, user_id, task_date</p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in">FROM <em><strong>only</strong></em> task</p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in">WHERE task_id IN (1, 2, 3);</p></div><div>Best regards.</div><div>Samed YILDIRIM</div><div> </div><div> </div><div> </div><div>01.04.2020, 16:49, "Heinemann, Manfred (IMS)" <heinemannm(at)imsweb(dot)com>:</div><blockquote><div lang="EN-US"><div><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in">Can something explain why something like the following could happen?</p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in"> </p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in">INSERT INTO task_history (task_id, user_id, task_date)</p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in">SELECT task_id, user_id, task_date</p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in">FROM task</p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in">WHERE task_id IN (1, 2, 3);</p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in"> </p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in">ERROR: insert or update on table "task_history" violates foreign key constraint "fk_task_history_task_id"</p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in"> Detail: Key (task_id)=(1) is not present in table "task".</p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in"> </p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in">Thanks,</p><p style="font-family:'calibri' , sans-serif;font-size:11pt;margin:0in 0in 0.0001pt 0in">Manfred</p></div> <hr /><br /><font face="Arial" size="1">Information in this e-mail may be confidential. It is intended only for the addressee(s) identified above. If you are not the addressee(s), or an employee or agent of the addressee(s), please note that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender of the error.</font></div></blockquote>