Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: None  |  size: 0.70 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. SQL insert subquery error
  2. INSERT INTO Work_Order (ID ,BRANCHID,BRANDID)  
  3. VALUES (66),
  4. SELECT ID FROM Brands WHERE NAME = 'branch'
  5. SELECT ID FROM Branches WHERE NAME = 'brand'
  6.        
  7. INSERT INTO Work_Order (ID ,BRANCHID, BRANDID)
  8.     select 66, branches.id, brands.id
  9.     from brands cross join branches
  10.     where branches.NAME = 'branch' and
  11.           brands.NAME = 'brand'
  12.        
  13. INSERT INTO Work_Order (ID ,BRANCHID,BRANDID)
  14. SELECT
  15.   66 AS ID,
  16.   (SELECT ID FROM Brands WHERE NAME='branch') AS BRANCHID,
  17.   (SELECT ID FROM Brands WHERE NAME='brand') AS BRANDID
  18.        
  19. INSERT INTO Work_Order (NUMBER,BRANDID,BRANCHID)    
  20. SELECT 66,B.ID,Br.ID
  21. FROM Brands as B,Branches as Br
  22. WHERE B.NAME = 'brand' AND Br.NAME = 'branch'