Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I will go with MATCH-AGAINST which should be better for MySQL optimized search like search engines. You should view full text searcing: <a href="http://dev.mysql.com/doc/refman/5.5/en//fulltext-search.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.5/en//fulltext-search.html</a></p> <p>NOTE: in a MySQL table should be INDEX-ed as FULLTEXT of keyword row in a table of database. This would give a greater performance for searching.</p> <p>Example:</p> <p>Example of input keywords:</p> <p>$keywords = '+Word+Word2+Word3';</p> <pre><code>SELECT p.page_url AS url, COUNT(*) AS occurrences, MATCH('w.word_word') AGAINST ('$keywords') as keyword FROM page p, occurrence o, w.word WHERE MATCH ('w.word_word') AGAINST('{$keywords}' IN BOOLEAN MODE) AND p.page_id = o.page_id AND w.word_id = o.word_id GROUP BY p.page_id ORDER BY occurrences DESC LIMIT $results </code></pre> <p>In other de-optimized mode or risky for slowing performance server if your queries are not opitmized (too many groups, where clauses and conditionals). Instead of this you can use REGULAR EXPRESSION in MySQL for example:</p> <pre><code>REGEXP "/(honda)|(jazz)|(manual)/" </code></pre> <p>This will also get a good performances using regular expressions (not recommended for huge db):</p> <p>Make a loop and count it than put in REGEXP:</p> <pre><code>$keywords = "keyword1,keyword2,keyword3"; $expl = explode("," $keywords); if (count($expl) == 1) { $all = w.word_word REGEXP = '[[:&lt;:]]$keywords[[:&gt;:]]'; } else { $all = ''; foreach ($expl as $keyone) { $all .= 'OR '.w.word_word REGEXP = '[[:&lt;:]]$keyone[[:&gt;:]]'; } } $sql = 'SELECT p.page_url AS url, COUNT(*) AS occurrences FROM page p, word w, occurrence o WHERE p.page_id = o.page_id AND w.word_id = o.word_id AND $all GROUP BY p.page_id ORDER BY occurrences DESC LIMIT $results'; $result_query = mysql_query($sql); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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