I have an insert query with two subqueries:
INSERT INTO Work_Order (ID ,BRANCHID,BRANDID)
VALUES (66),
SELECT ID FROM Brands WHERE NAME = 'branch'
SELECT ID FROM Branches WHERE NAME = 'brand'
I know it’s not a correct syntax but I need the correct one,
the ID must be 66 and BRANCHID,BRANDID are foreign keys for another tables
If your subqueries return more than one row, you have to decide how to combine the values. The following query assumes you want all combinations:
(I changed the where clause to look for the name within the same table as the name . . . branches.Name = ‘branch’ rather than branches.name = ‘brand’.)