title: How to use 3 conditions in SQL properly which is SUBSTRING, IF ELSE, EXISTS on making a data unique?
body: <p>So I haven't figured out my problem when it comes to my query, I want to get the first 3 strings of my data and make it unique for example I inputted GTX-2070 if I input another first 3 strings that is GTX-3070 it should not be accepted because the first 3 initial is already used. I tried to do this first in mysQL query.</p>
  <p>Here is my code in mySQL</p>
  <pre class="lang-sql prettyprint-override"><code>SELECT (CASE WHEN (IF EXISTS(SELECT SUBSTRING(control_no, 1, 3) FROM tools_masterlist BEGIN INSERT IGNORE INTO tools_masterlist (tools_id, tools_name, control_no)
  VALUES ('value a', 'value b', 'value c') END) THEN 'Error input' ELSE = 'Okay' END)) FROM tools_masterlist WHERE control_no = 'GTX-2070'
  </code></pre>
  <p>I am still figuring it out because I got errors in mySQL query and can't find the solution. Thank you for the help</p>