Note that there are some explanatory texts on larger screens.

plurals
  1. POSplit Letters Into Combination Chunks w/ Simplified Query
    text
    copied!<p>It's a confusion problem - so the wording may seem hard to follow. I'm likely over complicating a simple problem. Added an example question to help figure this out.</p> <h2>Example Question</h2> <p>Finding a 5 letter word from a database with the characters hxinenvarbav. I've organized the words in the DB to also contain a column of the word in alphabetical format. This means, the word "happy" has a column with the value "ahppy", so from the letters hxinenvarbav I can alphabetically organize them using the following code. </p> <pre><code>&lt;? $letters = str_split('hxinenvarbav'); asort($letters); $letters = implode('',$letters); // returns 'aabehinnrvvx' ?&gt; </code></pre> <h2>The Issue</h2> <p>However, I can't simply search with mysql "LIKE '%aabehinnrvvx%' " and find 5 letter words with those characters, as obviously that will not pull any results. Unless maybe there is a MySQL query I could do? Maybe organize the column differently. I can however, use str_split($letters,5) to take 5 letters chunks of the 12 letter combination.</p> <p>How would I go about, splitting in chunks each possible 5 letter combination from these 12 letters while keeping in mind, I need to query the table.</p> <p>Does this make sense? Do I need to elaborate any further? Likely, I'm just over thinking and can't seem to simplify what it is I'm trying to accomplish. I have some complex mathematics that can find all possible combinations. But since I have placed in alphabetical order, I'm only searching combinations - not permutations. And on top of that, I don't <em>need</em> to as far as I logically believe, query 'each' combination. As there are 792 possible 5 letter combinations from only 12 letters (without calculating repeating characters). So 792 query calls is not nice - and 792 OR statements in my query, is clearly not an option. LOL!. </p> <p>Any suggestions?</p> <p>I did just think about searching via available characters left from alphabet - but, some words have repeating letters so that's not an option either.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload