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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:33:01+00:00 2026-06-06T09:33:01+00:00

On a site I’m doing a user can enter a search string like do

  • 0

On a site I’m doing a user can enter a search string like

 "do you have foo bar"

I’m using Coldfusion8 to create a |-delimited list like so:

<cfif len(LOCAL.Search.s_artikelbezeichnung) GT 0>
    <cfloop list="#LOCAL.Search.s_artikelbezeichnung#" delimiters=", " index="terms">
        <cfset variables.searchTerms = variables.searchTerms & terms & '|'>;
    </cfloop>   
    <cfset variables.searchTerms = Left(variables.searchTerms, len(variables.searchTerms)-1)>
</cfif>

Which should give me:

 do|you|have|foo|bar    // param_artikelbezeichnung

In MySQL I’m then doing a REGEX:

...
AND ( (param_artikelbezeichnung = '') AND (1=1) 
    OR (
        a.artikelbezeichnung REGEXP param_artikelbezeichnung 
        )

My Question:
Do I have to add quotation marks ” around my variable or can I enter it like this? I have a bunch of dynamic criteria I need to add to a search, so I’m looking for some general info.

Thanks for help!

EDIT:
Ok this is what I’m getting from the database:

  a.artikelbezeichnung REGEXP param_artikelbezeichnung 
     >> using foo|bar OK
  a.artikelbezeichnung REGEXP param_artikelbezeichnung
     >> not passing a value > ERROR

So I don’t need quotation marks, but I need to pass something to the regex to not produce an error on empty fields. Would something like this work:

   AND ( (param_artikelbezeichnung = '') AND (0=1) 
      OR (  a.artikelbezeichnung REGEXP param_artikelbezeichnung )

Almost another question. Thanks for answering!

  • 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-06T09:33:02+00:00Added an answer on June 6, 2026 at 9:33 am

    According to the mysql doc you need to put the search string/regex in single quotes like this:

    AND ( (param_artikelbezeichnung = '') AND (1=1) 
        OR (
            a.artikelbezeichnung REGEXP 'do|you|have|foo|bar'
            )
    

    Otherwise it will produce a syntax error in mysql.


    Update:

    Since you’re in a stored procedure, you can do it like this. For other readers: param_artikelbezeichnung is an argument of the stored procedure which is called by coldfusion.

    SELECT COUNT(a.id) AS recs, a.artikelnummer, a.nos, a.nos_anzeige
    FROM artikel AS a
    WHERE a.aktiv = 'ja'
    AND a.artikelbezeichnung REGEXP IF(artikelbezeichnung = '', '.', artikelbezeichnung )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My site is going to have some inline code (when using the foo() function...)
My site has its own login system and the user can choose to connect
Our site is using ASP.Net Membership. I have a page which literally has nothing
Site in question: http://www.sedulity.tk/ Site using Chrome 19 dev: Site using IE9: as you
Site here. Basically the box in the middle doesn't generate random string from my
SITE ADMIN: WOULD YOU PLEASE REMOVE THIS POST? For example, I have tt =
Site is Located @ beattrainsoundsystem.com/home I'm using serialScroll to animate a number of divs
Site: http://na.leagueoflegends.com/ladders/solo-5x5 Search for a a player (example: Jaiybe) You get redirected (in this
Test site: http://wfwgm.stage.philosophydesign.com/ I have included: <script src=http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js></script> to give :before support in IE6
I have a French site that I want to parse, but am running into

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.