0 Members and 1 Guest are viewing this topic.
You're probably looking for a foreign key to the company. That way if you go to insert it, if the company doesn't exist, it will fail to insert.
https://www.techonthenet.com/mysql/exists.php should do it for you
Quote from: Miss Silabsoft on January 29, 2015, 03:56:47 PMhttps://www.techonthenet.com/mysql/exists.php should do it for youFrom that post:Code: SQLINSERTINTO contacts(contact_id, contact_name)SELECT supplier_id, supplier_nameFROM suppliersWHEREEXISTS(SELECT* FROM orders WHERE suppliers.supplier_id = orders.supplier_id);That's the type of thing I mean, but I was wondering if it was possible to use some sort of relationship to integrate this directly into the table design without having to use a special query with each insert.For example, if I created another table that contained the company names as a primary key only, then I could create a relationship from that name, to the company plant name, then to the plane company name (or an id relating to that key)I think I am going to kind of do something like that instead. The exact thing this is being used for is NPC drop tables, I wanted to link NPC definitions to the drop tables there, but instead I think Im going to do something like create a table oftable_id, npc_idsand then the drops tables are just linked to the table id