Mysql insert a row only if id exist in another table
<p>I have 2 simple table</p>

<ul>
<li>table1 -> p_id | s_id</li>
<li>table2 -> p_id | s_id</li>
</ul>

<p>The two table are same. <strong>The p_id ai value</strong>.</p>

<p>I would like to insert into the table2 a row, but **only if p_id is exist in table1. This is possible? (MySQL)</p>

<pre><code>INSERT INTO table1 (p_id, s_id)
SELECT * FROM (SELECT '100', '2') AS tmp
WHERE NOT EXISTS (SELECT p_id FROM table2 WHERE p_id = '100')
LIMIT 1
</code></pre>