OK..OK it's a bit large text but the problem is quite straightforward 😉
I have a table with 16 columns. I want to see if a record in this table exist, if it does not insert the record if it does pull the primary key for that record, in both ways I want to be left with the primary key of a record with the data I want. In order to see if a the record exist my only option is select from table1 where a1=value1,...,a16=value16 (all the fields must be checked) after the if else statement in the case of an insert which is the better solution?
a) to do another select from table1 where a1=value1,...,a16=value16 to get the id of the new record or
b)to have another table e.g. tablenum with values from which I will draw the value, use it in my insert, update the value and reenter in in tablenum. In this case I will already know the id of the record inserted in tanle1 without doing the select again.
The b) solution has more code however I prefered it since table1 can become very large eventually and then won't the select * from table1 where a1=value1,...,a16=value16 slow my page very much? (I already do it once to check for existing records I guessed a second one to pull the Primary Key is too much)
What do you think?