SQLite does not support variables.
You can use a CTE that returns the values of the 2 variables as columns:
WITH cte(var1, var2) AS (
SELECT (SELECT Id FROM Table1 WHERE id = 'val1'), (SELECT Id FROM Table2 WHERE id = 'val2')
)
INSERT INTO Table3(id_1, id_2)
SELECT var1, var2
FROM cte
WHERE NOT EXISTS (SELECT * FROM Table3 t3 INNER JOIN cte c ON t3.id_1 = c.var1 AND t3.id_2 = c.var2);
INSERT INTO Table4(id, `desc`)
SELECT '111', 'new entry'
WHERE NOT EXISTS (SELECT * FROM Table4 WHERE id ='val3')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…