I have a looklup table, its got an ID and a NAME field. The process I’m currently going through is:
Lookup Name. If the row count equals 1, return the ID. If the row count is 0, insert the new name and return the new ID. If there is more than 1 row, log the error and return the 1st ID.
This consists of a SELECT then an INSERT in the case of a new name. Is there a way to combine this so there is only a single SQL statement executed?
Even if that is possible which I’m confident it’s not it should be illegal. Your cramming way too much logic into the SQL code.