I am using SQLITE and I have two tables Teams and Fixtures.
I want to add new fixtures using the ID from the Teams table as the Team_Name but if the Team_Name doesn’t exist in Teams I want to add it to Teams before then doing the INSERT INTO Fixture.
I have this so far ...
INSERT INTO Fixture
VALUES (
Select ID from Teams where Team_Name = ‘Home Team’
);
Which I think will work where the name exists. (I’m unable to test as away from the computer and trying to write the codes in notes to test later).
I have tried looking on multiple sites and I have a basic SQL for beginners book but I’m not sure how to write in the extra bits as all I can find is regarding INSERT INTO IF NOT EXISTS using one table.
I hope I’ve written this question suitably but any advice and guidance on better putting questions across would be gratefully received as I am new to SQL and these forums.