innovatio Posted September 6, 2015 Share Posted September 6, 2015 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 from the blog post here: http://www.titov.net/2005/09/21/do-not-use-order-by-rand-or-how-to-get-random-rows-from-table/ 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! Quote Link to comment https://forums.phpfreaks.com/topic/298075-combining-random-order-with-regexp-search/ Share on other sites More sharing options...
scootstah Posted September 9, 2015 Share Posted September 9, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/298075-combining-random-order-with-regexp-search/#findComment-1520572 Share on other sites More sharing options...
innovatio Posted September 11, 2015 Author Share Posted September 11, 2015 On 9/9/2015 at 7:05 PM, scootstah said: 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. Quote Link to comment https://forums.phpfreaks.com/topic/298075-combining-random-order-with-regexp-search/#findComment-1520692 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.