title: how to check if entry exists before inserting in sql table
body: <p>I have a table called <code>Panels</code> as below with the following entry as of now.</p>
  <pre><code>---Panel table
  
      p_id    sequence    p_type  
        1       2          '3a'
   ... and many more rows
  
  </code></pre>
  <p>I am using the following query to insert into the <code>Panels</code> table a new entry with <code>p_type='4a'</code>. In order to create the new entry, I will use the <code>p_type='3a'</code>. My issue is that how can I check if the entry for p_type='4a' already exists in the table before doing the INSERT INTO.</p>
  <p>Trying to find a solution online, I found a template code such as the follows.</p>
  <pre><code>if not exists (select column_1 from table_name where column_1 = value)
  begin
      insert statement here
  end
  go
  </code></pre>
  <p>My Insert logic is as the following:</p>
  <pre><code>INSERT INTO Panels (p_id,sequence,p_type) 
          SELECT p_id,sequence,'4a'
          FROM Panels
          WHERE p_type='3a'
  </code></pre>
  <p>The issue I am having is that I dont know how to intergrate the template code logic I have above with my INSERT INTO statement. Can someone help me with it?</p>