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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:54:49+00:00 2026-06-15T07:54:49+00:00

not done many MySQL functions before… So, I am looking to have my function

  • 0

not done many MySQL functions before… So, I am looking to have my function count the number of needles in the haystack below. I keep getting:

#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 7

Which is the line with “RETURN,” Here is what I have:

DELIMITER $$

CREATE FUNCTION `str_count`(needle TEXT, haystack TEXT) 
RETURNS INT(5)
BEGIN

  RETURN (LENGTH(haystack) - LENGTH(REPLACE(haystack, needle, ""))) / LENGTH(needle);

END$$

Never done this kind of function before, so any help is greatly appreciated!

Thanks in advance!

  • 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-15T07:54:50+00:00Added an answer on June 15, 2026 at 7:54 am

    Well, I feel silly. When running this kind of stuff, make sure you define the Delimiter in the phpMyAdmin text box below the SQL textarea… In my case “$$” but it works great now!

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

Sidebar

Related Questions

I think I have done this before, but it could also be a function
I have not done any animation stuff with iphone development so far. Can anybody
I have not done any large game development projects, only messed around with little
I would appreciate some help with something I working on and have not done
I want to do a simple drag-drop using jQuery. I have not done anything
(Not my real MySQL schema, but illustrates what needs done.) Users can belong to
i have a mysql db, and i have one table which has many columns
I have done many CodeIgniter projects and in that i have only used $this->db->query
Recently I have started getting mySQL too many connection errors at times of high
New to mysql and have been told by many, that creating foreign keys in

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.