Help on Error:Only one expression can be specified in the select list when the subque

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • XolileWarren
    New Member
    • Dec 2008
    • 4

    #1

    Help on Error:Only one expression can be specified in the select list when the subque

    Hi Everyone

    I'm trying to create a stored procedure that will delete groups that are in-active for a month.

    Table description i have two table which are linked together using groupID, when creating the group group info is stored into the group table including the date group was created, and when posting comment to the group, content is stored into the groupPost table.

    I have the isDelete column on both table which is a bit data-type - for the group row to be de-actived i need to set is delete column to true.

    where is my stored procedure:
    [code=mysql]
    CREATE PROCEDURE dbo.DeleteInAct iveGroups
    AS
    UPDATE
    dbo.GroupPost
    SET
    dbo.GroupPost.i sDeleted = 1
    WHERE
    dbo.GroupPost.G roupID
    IN
    (
    SELECT
    *
    FROM
    dbo.Groups
    WHERE
    dbo.Groups.Date Created < DATEADD(MONTH, -1, GETDATE())
    AND
    Groups.UserID <> 37 OR Groups.UserID <> 36
    )
    [/code]
    I keep on getting an error:Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

    Any help will be appreciated. Thanks in advance
    Last edited by Atli; Jan 29 '09, 09:02 PM. Reason: Added [code] tags.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    That doesn't look like MySQL code to me.
    Which SQL server are you using?
    Microsoft's SQL Server perhaps?

    Let me know and I'll move this to the proper forum.

    Comment

    • XolileWarren
      New Member
      • Dec 2008
      • 4

      #3
      Reply to SQL Server Version

      Apologies, i didn't notice i'v posted to the wrong forum, it's SQL, I'm currently using SQL Server 2005, Enterprise Edition

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        Change your subquery to:

        Code:
        SELECT GroupID
        FROM dbo.Groups
        WHERE
        dbo.Groups.DateCreated < DATEADD(MONTH, -1, GETDATE())
        AND 
        Groups.UserID <> 37 OR Groups.UserID <> 36
        IN have some problems handling NULL. Read more about it here

        Happy Coding!


        -- CK

        Comment

        Working...