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 723371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:06:02+00:00 2026-05-14T06:06:02+00:00

I use the following mysql query, DELIMITER $$ DROP PROCEDURE IF EXISTS `allied`.`aboutus_delete`$$ CREATE

  • 0

I use the following mysql query,

DELIMITER $$
DROP PROCEDURE IF EXISTS `allied`.`aboutus_delete`$$
CREATE DEFINER=`allied`@`%` PROCEDURE `aboutus_delete`(
IN p_Id int(11)
)
BEGIN
   if exists(   select aboutUsId 
                  from aboutus 
                 where aboutUsId=p_id 
                   and isDeleted=0
            )
      update aboutus set isDeleted=1 where aboutUsId=p_id
   else
      select 'No record to delete'
END$$
DELIMITER ;

But i get this error when i execute it…

Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds 
to your MySQL server version for the right syntax to use near 
'update aboutus set isDeleted=1 where aboutUsId=p_id
else
   select 'No record to' at line 6

EDIT:

using semicolon doesn’t seem to work,

if exists(select aboutUsId from aboutus where aboutUsId=p_id and 
 isDeleted=0) then
   update aboutus set isDeleted=1 where aboutUsId=p_id;
else
   select 'No record to delete';
  • 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-05-14T06:06:02+00:00Added an answer on May 14, 2026 at 6:06 am

    This is a different issue: you can optimize this procedure a bit. Why hit the datastore twice when one query will do? Just set the isDeleted attribute to 1 and check the row_count value afterwards.

    BEGIN
      UPDATE aboutus SET isDeleted = 1 WHERE aboutUsId = p_id AND isDeleted = 0;
      IF (SELECT row_count()) <= 0 THEN
        SELECT 'No record to delete';
      END IF;
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following mysql procedure, DROP PROCEDURE IF EXISTS `allied`.`GetRegistrationData`$$ CREATE DEFINER=`allied`@`%` PROCEDURE
I'm running the following query throug a PHP script DROP TABLE IF EXISTS `address`;CREATE
I created one procedure called Sample1 delimiter ;; drop procedure if exists Sample1;; CREATE
Modifed. DROP FUNCTION IF EXISTS PersonName; DELIMITER |; CREATE FUNCTION PersonName( personID SMALLINT )
I use the following rsync command to backup my MySQL data to a machine
I want to merge data. Following are my MySQL tables. I want to use
The following error is returned when trying to use a MySQL function.. #1418 -
I use odbc to interface mysql. I start odbc by the following code: ConnectString
In the following example, MySQL fails to use to find a ref for the
I use following code: Create a retry policy, when error, retry after 1 second,

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.