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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:01:13+00:00 2026-05-15T17:01:13+00:00

I need a some stored procedure that called like: search(‘foo bar’) makes a search

  • 0

I need a some stored procedure that called like:

search('foo bar')

makes a search similar to:

SELECT FROM A, B
WHERE A.B_ID = B.ID
AND (A.f1 LIKE '%foo%' OR A.f2 LIKE '%foo%' OR B.f3 LIKE '%foo%')
AND (A.f1 LIKE '%bar%' OR A.f2 LIKE '%bar%' OR B.f3 LIKE '%bar%')

And I have some doubts and questions:

  1. I can’t pass an array to the procedure, so my only option is to pass the string directly as in the example (‘foo bar’)?

  2. So I assume I have to do the split in SP code. I didn’t know how, so I searched and found this solution. Is using temporary tables and what I think a lot of clumsy code. Is really so complicated? How about the performance?

  3. I don’t know how to create such dynamic query. I suppose I have to loop over the tokens to create a new block of the WHERE clause for everyone, but I’m not sure how to do this or if it’s the best solution. Maybe concatenating strings and then making a prepared statement is better?

Thanks.

Note: I use iBATIS (Java) for calling this routine.

  • 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-15T17:01:14+00:00Added an answer on May 15, 2026 at 5:01 pm

    What you want is to use Full Text Searching (FTS) – there’s MySQL’s native FTS functionality which can only be used on MyISAM tables, and 3rd party FTS like Sphinx, to choose from. Here’s an online slideshow that’s a decent intro & howto.

    Using MySQL native FTS, your query would resemble:

    SELECT *
      FROM A AS a
      JOIN B AS b ON b.id = a.b_id
     WHERE MATCH (a.f1, a.f2, b.f3) AGAINST ('foo bar');
    

    Dynamic SQL is still an option, depending on how strong you want/need to make the query. I’d look into the FTS offerings before I’d consider dynamic SQL…

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

Sidebar

Related Questions

I need to make some changes to an old Oracle stored procedure on an
My App need to save some data (around 100 double fields that is stored
I need some help in combining a stored procedure with another function. I've got
I have a SQL stored procedure that I need to execute several times with
I need to use a cursor to call a stored procedure that has 2
I am working on a stored procedure that performs some operations on students in
I need to create a stored procedure that needs to return a count of
I need to create a Postgres 9.1 PL/pgSQL stored procedure that, among other parameters,
I have a lotus view that stores a number. I need to perform some
I have a stored procedure that returns a list of projectIDs at the moment.

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.