Jump to content

Combining Random order with REGEXP Search


innovatio

Recommended Posts

I wish to execute a REGEXP search but by a random mechanism. I've used ORDER BY RAND() before but it is getting too performance costly to where I am to evolve to other methods. Here is the REGEXP function in question:

 

 

$searchCD = "SELECT * FROM `table` WHERE `foo` ||', '||

         `bar`  REGEXP '".$keywords."' ";

        $searchST = $con->query($searchCD);

 

 

The alternative order random I wish to splice it with:

 

The

 

SELECT quote FROM quotes LIMIT $generated_number, X

 


 

I've tried numerous times to splice the two methods myself, but nothing works. I would consider other methods, but I don't know how to approach the issue of my database containing missing records from deleted accounts. Thanks!

Link to comment
Share on other sites

Can you post your schema and what you're trying to search for with $keywords?

 

Kind of sounds like a not very efficient schema layout.

 

So my schema goes along something like this:

Table: foobar

foo: words specific to foo
bar: words specific to bar

The query basically selects the querys with common "keywords" found in $keywords. The schema layout isn't bad at all. What I am trying to do is to display the matched records in random order.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.