I am trying to insert an element into one table, where one of the values is an ID of an item from other table. I have found example but I can't make it work with my situation. Basically I can't wrap my head around this.
This is how I'm trying to create my statement:
sql = @"INSERT INTO SectionLocations(sectionId, roomNum, buldingId)
VALUES('" + parent + "', '" + room + "',
SELECT 'building' FROM Buildings WHERE building='" + building + "');";
So The Buildings table has field named ID, how would I insert that ID field there?
Aucun commentaire:
Enregistrer un commentaire