A field in my table is labeled sha1. When I insert rows into this table I first need to check and make sure the sha1 field of the row I am inserting does not match the sha1 field of any existing row in the table. Is there a sql-only way of accomplishing this without having to first read the table into an array and compare it against my INSERT every INSERT?
"SELECT 1 FROM table WHERE sha1 = value" If a row is returned then the value already exists. You should also give the column a unique key so MySQL won't insert rows with duplicate values for the sha1 column. If you just don't want the row inserted then you don't need to do the select. If you need to know if the key already exists then you have to do the select.