How can I Select duplicate results, insert the results to a new table and delete them from the original table? (phpmyadmin)
<p>I have 2 tables, both with the same column names that look like this</p>

<p><a href="https://i.stack.imgur.com/bLkcF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bLkcF.png" alt="enter image description here"></a></p>

<p>I have an app that is used for clocking in/out. A user goes up to a tablet and selects there name, the data is then inputted into table 'clocktable' as shown above. </p>

<p>What I need to happen is when a user presses their name for a second time (to clock out) it detects that there is already a value in the table with the same employeename value, and moves both clocks to a different table 'oldclocks' so that a record is kept of clocking in/out times. The reason it needs to be in a separate table is I have a web page that displays the 'clocktable' table so we can determine who is in the building.</p>

<p>How can I go about doing this? 
I can execute   </p>

<pre><code>SELECT DISTINCT EmployeeName, time FROM clocktable ORDER BY EmployeeName
</code></pre>

<p>from within myphp and then execute </p>

<pre><code>INSERT INTO oldclocks SELECT Employeename, Department, time FROM clocktable;
</code></pre>

<p>Afterwards, but I cannot seem to execute them both at the same time in order to get them into a php script. Also is there a way I can delete the select results from the 'clocktable' at the same time? </p>

<p>Help with this would be greatly appreciated. </p>