错误消息获取子查询返回的值超过1。这个查询中的错误是什么

时间:2017-07-20 11:24:44

标签: sql sql-server sql-server-2008

INSERT INTO [BOOnboardingStatus]
            (BusinessID,
             SectionID,
             SectionName,
             SubSectionID,
             SubSectionName,
             status,
             createdby,
             modifieddate,
             modifiedby,
             source,
             createddate)
SELECT contentid,
       2,
       'Additional Info',
       '22',
       'Add keywords',
       (SELECT CASE
                 WHEN categoryname IS NOT NULL THEN 1
                 ELSE 0
               END
        FROM   businesscategory
        WHERE  businessid IN(SELECT contentid
                             FROM   businessmaster
                             WHERE  isclaim = 1)
               AND [primary] = 1),
       1,
       Getdate(),
       0,
       'BOD',
       Getdate()
FROM   businessmaster
WHERE  isclaim = 1 

1 个答案:

答案 0 :(得分:0)

据推测,您需要一个相关的子查询:

mysqli_close($this->link);

编辑:

也许SELECT contentid, 2, 'Additional Info', '22', 'Add keywords', (SELECT CASE WHEN categoryname IS NOT NULL THEN 1 ELSE 0 END FROM businesscategory bc WHERE bc.businessid = bm.contentid AND bc.[primary] = 1 ), 1, Getdate(), 0, 'BOD', Getdate() FROM businessmaster bm WHERE isclaim = 1 ; 可以满足您的需求。它肯定会摆脱错误:

EXISTS