
Untitled
By: a guest on
Aug 10th, 2012 | syntax:
None | size: 0.70 KB | hits: 11 | expires: Never
SQL insert subquery error
INSERT INTO Work_Order (ID ,BRANCHID,BRANDID)
VALUES (66),
SELECT ID FROM Brands WHERE NAME = 'branch'
SELECT ID FROM Branches WHERE NAME = 'brand'
INSERT INTO Work_Order (ID ,BRANCHID, BRANDID)
select 66, branches.id, brands.id
from brands cross join branches
where branches.NAME = 'branch' and
brands.NAME = 'brand'
INSERT INTO Work_Order (ID ,BRANCHID,BRANDID)
SELECT
66 AS ID,
(SELECT ID FROM Brands WHERE NAME='branch') AS BRANCHID,
(SELECT ID FROM Brands WHERE NAME='brand') AS BRANDID
INSERT INTO Work_Order (NUMBER,BRANDID,BRANCHID)
SELECT 66,B.ID,Br.ID
FROM Brands as B,Branches as Br
WHERE B.NAME = 'brand' AND Br.NAME = 'branch'