I have to fix a program error, which should find those entries in table1 which do not have matching records in table2 and then insert records in table2, so that for each record in table1 there should be at least one corresponding match in table2.
First I am trying to return IDs in table1, which do not have a corresponding match in the second table and then want to insert. Below is the query which is not working as per expectation:
INSERT into Services(Services.FkLobbyId, Services.FkServiceId, Services.ServiceTime)
values (LobbyId, '26','1')
(Select LobbyId FROM Lobby WHERE (NOT EXISTS (SELECT FkLobbyId FROM ServiceProvided WHERE (Lobby.LobbyId = FkLobbyId))))