|
If I follow this correctly, you want to simply use a foreign key constraint. The key relation will require a record in one table that already has a corresponding key in the second. So this second table would insert all the valid records, then the key relation is placed on the first table, and you simply attempt to insert. If it provides no affected rows after the insert, it will trigger an error indicating a key violation, which is simply the answer for no valid foreign key constraint was satisfied.
If you don't need to store input, than a simple select would tell you if it already exists. It's not clear how you are intending to use the existing disc_id.gamecode in relation to the gamecode via input.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
|