Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8385183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:36:21+00:00 2026-06-09T17:36:21+00:00

Error: Result consisted of more than one row I think the problem is with

  • 0

Error: Result consisted of more than one row
I think the problem is with word LIMIT
Can sb help with this ?

DELIMITER $$

CREATE PROCEDURE `InsertComment`(crc int(11) unsigned, userId int, title varchar(255),
                nick varchar(20), parentId int, content text)
BEGIN

         DECLARE tableName VARCHAR(4);
         DECLARE tbName VARCHAR(15);    
         DECLARE results INTEGER;
         DECLARE depth integer;
         DECLARE results2 INTEGER;
         DECLARE resultsM INTEGER;
         DECLARE commentsId INTEGER;
         DECLARE CommentX INTEGER ;
         DECLARE COUNTER INTEGER;


         set tbName = CAST(crc AS CHAR);
         set tableName = SUBSTRING(tbName, 1, 5);




        CALL CreateCommentsTable(tableName);

        if parentId = 0 then

                SET @results2 = 0;

                SET @q2 = CONCAT("SELECT commentsId INTO @results2 FROM `",tableName,"` WHERE CRC32 = ",crc," ORDER BY commentsId DESC LIMIT 1");
                    PREPARE stmq2 FROM @q2;
                    EXECUTE stmq2;
                    DEALLOCATE PREPARE stmq2;

                SET commentsId = @results2 + 1;

                SET depth = 0;
                SET @results = 0;

            else

                    SET @q2 = CONCAT("SELECT Depth INTO @results FROM `",tableName,"` WHERE CRC32 = ",crc," AND commentsId = ",parentId);
                                PREPARE stmq2 FROM @q2;
                                EXECUTE stmq2;
                                DEALLOCATE PREPARE stmq2;

                    set depth = @results;
                    set depth = depth + 1;

                    set @CommentX = 0;
                    SET @COUNTER = 0;


                WHILE @COUNTER = 0 AND @results > -1 DO


                            SET @q4= CONCAT("SELECT COUNT(*) INTO @COUNTER FROM `",tableName,"` WHERE CRC32 = ",crc," AND Depth = ",@results," AND commentsId > ",parentId);
                            PREPARE stmq2 FROM @q4;
                            EXECUTE stmq2;
                            DEALLOCATE PREPARE stmq2;

                            IF @COUNTER > 0 THEN

                                SET @q3= CONCAT("SELECT commentsId INTO @CommentX FROM `",tableName,"` WHERE CRC32 = ",crc," AND Depth = ",@results," AND commentsId > ",parentId," ORDER BY commentsId ASC Limit 1" );
                                PREPARE stmq2 FROM @q3;
                                EXECUTE stmq2;
                                DEALLOCATE PREPARE stmq2;


                            END IF;

                            SET @results = @results - 1;



                END WHILE;

                            SET @resultsM = 0;

                            IF @CommentX = 0 THEN
                                  SET @q2 = CONCAT("SELECT commentsId INTO @resultsM FROM `",tableName,"` WHERE CRC32 = ",crc," ORDER BY commentsId DESC LIMIT 1");

                                  PREPARE stmq2 FROM @q2;
                                  EXECUTE stmq2;
                                  DEALLOCATE PREPARE stmq2;

                                SET commentsId = @resultsM +1;


                                else

                                      SET commentsId = @CommentX + 1;

                            END IF;


                SET @u = CONCAT("UPDATE `",tableName,"` SET commentsId = commentsId + 1 WHERE CRC32 = ",crc,"  AND commentsId > ",commentsId + 1);
                PREPARE stmq FROM @u;
                EXECUTE stmq;
                DEALLOCATE PREPARE stmq;

        end if;

        SET @a = CONCAT("INSERT INTO `", tableName ,"` (`Crc32`, `UserId`, `Title`, `Nick`, `CommentsId`, `Depth`, `Content`, `CommentStatus`, `ViewStatus`) 
                         VALUES (",crc,", ",userId,", '",title,"', '",nick,"',",commentsId,", ",depth,", '",content,"', 1, 1);");
        PREPARE stmi FROM @a;
        EXECUTE stmi;
        DEALLOCATE PREPARE stmi;

        set @results = null;
        set @results2 = null;
        set @tableName = null;
        set @tbName = null;

END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:36:22+00:00Added an answer on June 9, 2026 at 5:36 pm

    If you use Delimiter $$ then all the ; inside your stored procedure should be replaced with $$. You should also set back the delimiter to ; at the end of your command.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting this error: Result consisted of more than one row I have
i have this JSON object: {error:null, result:[{id:1234567890, count:1, recipients: [u3848, u8958, u7477474 ], dateCreated:2012-06-13T09:13:45.989Z
I use the following jquery statements but i get error in this function onGetDataSuccess(result)
CSS/HTML problem. This is crazy - I can only assume that I am an
In the struts.xml I use: <result name=error>error</result> Then in my action I use: addActionError(ERROR
#include vss.h #include vswriter.h #include <VsBackup.h> #include <stdio.h> #define CHECK_PRINT(result) printf(%s\n,result==S_OK?S_OK:error) int main(int argc,
i Have a problem returning multiple rows in one output there are multiple user_roleID's
I really need help on this because I lost my hopes to correct the
I created one procedure called Sample1 delimiter ;; drop procedure if exists Sample1;; CREATE
The docs for Control.Monad.Trans.Error provide this example of combining two monads: type ErrorWithIO e

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.