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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:35:59+00:00 2026-06-10T03:35:59+00:00

DROP FUNCTION IF EXISTS shorten; delimiter $$ CREATE FUNCTION shorten(s VARCHAR(255), n INT) RETURNS

  • 0
DROP FUNCTION IF EXISTS shorten;
delimiter $$
CREATE FUNCTION shorten(s VARCHAR(255), n INT)
   RETURNS VARCHAR(255)
 BEGIN
 IF ISNULL(s) THEN
   RETURN '';
 ELSE IF n<15 THEN
    RETURN LEFT(s, n);
 ELSE IF CHAR_LENGTH(s) <= n THEN
   RETURN s;
 ELSE
  RETURN CONCAT(LEFT(s, n-10), ' ... ', RIGHT(s, 5));
  END IF;
 END$$

The message that I get is:

#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 ” at line 14
>

Where is teh error..cause I am new to making function in mysql.

UPDATE :

It points to an error with some rounded question mark between those lines:

ELSE IF n <15 THEN RETURN LEFT( s, n ) ;

ELSE IF CHAR_LENGTH( s ) <= n THEN RETURN s;

BTW, I use phpmyadmin

mysql version is: mysqlnd 5.0.10

  • 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-10T03:36:00+00:00Added an answer on June 10, 2026 at 3:36 am

    I am not sure bt i don’t understand why you close if (END IF;) two times..?
    This may be a probable problem in your code. Please check it.And ELSE IF should be without space i.e ELSEIF.
    The code should be:

    DROP FUNCTION IF EXISTS shorten;
    delimiter $$
    CREATE FUNCTION shorten(s VARCHAR(255), n INT)
    RETURNS VARCHAR(255)
     BEGIN
     IF ISNULL(s) THEN
     RETURN '';
     ELSEIF n<15 THEN
    RETURN LEFT(s, n);
     ELSEIF CHAR_LENGTH(s) <= n THEN
     RETURN s;
     ELSE
     RETURN CONCAT(LEFT(s, n-10), ' ... ', RIGHT(s, 5));
      END IF;
     END;$$
     delimiter;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

DROP FUNCTION IF EXISTS my_func; DELIMITER || CREATE FUNCTION my_func(arg_id INT) RETURNS VARCHAR(200) BEGIN
DELIMITER $$ DROP FUNCTION IF EXISTS `workplantype`.`FUN_STOCKINVENTRY_CHECK` $$ CREATE FUNCTION `workplantype`.`FUN_STOCKINVENTRY_CHECK` ( PONo1 VARCHAR(20),
I've this function: DROP FUNCTION IF EXISTS find_linkid; DELIMITER // CREATE FUNCTION `find_linkid`(pc1 VARCHAR(50)
DELIMITER $$ USE `horizon_jake`$$ DROP FUNCTION IF EXISTS `GPS_Distance_Meters`$$ CREATE DEFINER=`horizon_jake`@`localhost` FUNCTION `GPS_Distance_Meters`(lat1 DOUBLE,
I have this code DELIMITER $$ DROP FUNCTION IF EXISTS `GetNextID` $$ CREATE FUNCTION
Modifed. DROP FUNCTION IF EXISTS PersonName; DELIMITER |; CREATE FUNCTION PersonName( personID SMALLINT )
I've got a trivial MySQL function: DELIMITER $$ DROP FUNCTION IF EXISTS `mydb`.`CALC` $$
I have function to cal miles distance: DELIMITER // DROP FUNCTION IF EXISTS distance_miles//
function populateDB(tx) { tx.executeSql('DROP TABLE IF EXISTS test'); tx.executeSql('CREATE TABLE IF NOT EXISTS test(course
I'm writing a function which will drop a table if it already exists. It

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.