Hi,
This is really more of a MySQL question than PHP per se, but the only
MySQL group my newserver carries seems to be pretty quiet, so I
thought I'd ask here.
What I am trying to do is determine the number of terms which match a
field in the database where an initial string of multiple words has
been broken up into single terms and the SQL statement is built by
looping through each term separately, something like this:
$original_string = "this is a test string"
// code to remove stop words/common terms leaves
$trimmed = "this test string"
// this is then exploded at the space into an array of its constituent
words. This array is then looped over to pass each word to an SQL
query thus
$SQL = "select * from main where"
while(there are terms){
$SQL .= "Title like '%" . $term . "%' OR"
}
// this would lead, using the above example, to an SQL query which
looks like this:
$SQL = "SELECT * FROM main WHERE Title like '%this%' OR Title like
'%test%' OR Title like '%string%'
What I need to do is to check how many of the terms actually match
something. Is there any way, either in MySQL or with the result array
in PHP, to determine this?
Am I on completely the wrong course (as it seems to me at the
moment...)
tia
Chris 3 1336
On Wed, 18 May 2005 10:29:15 +0100, Chris wrote: What I need to do is to check how many of the terms actually match something.
I think the best way might be to maintain a separate index table with
terms. New search terms will be a bit slower. Alternatively, you could
just, in addition to your original query, have separate queries for each
term (using count() or using the rowcount of each result).
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
On Wed, 18 May 2005 11:49:14 +0200, Ewoud Dronkert
<fi*******@lastname.net.invalid> wrote: have separate queries for each term (using count() or using the rowcount of each result).
Hmmmm, that might just work, thanks! I think I've been staring at this
problem for so long that I missed the obvious!
Thanks again
C
Chris <Ch************@nez.oc.ku> wrote:
[snip] What I need to do is to check how many of the terms actually match something. Is there any way, either in MySQL or with the result array in PHP, to determine this?
Am I on completely the wrong course (as it seems to me at the moment...)
Ehhhh, it looks to me like you are trying to reinvent full text
searches ( http://dev.mysql.com/doc/mysql/en/fulltext-search.html) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Adam i Agnieszka Gasiorowski FNORD |
last post by:
I need help width formulating the most
effective (in terms of processing time)
SQL query to count all the "new"
documents in the repository, where "new" is
defined as "from 00:00:01 up to...
|
by: cassandra.flowers |
last post by:
Hi,
I have another string handling question for the group, since you have all
been so helpful in the past. Thank you.
Basically, I want to do something really simple:
Search a main...
|
by: dd |
last post by:
Given the bolow sample, I need to count the elements <quick> with a
child 'yes'. The result for this sample should, of couse, be '1', but I
cannot figure out how to write the expression in the...
|
by: rob.guitar.rob |
last post by:
Hi,
This may be a stupid question, but if you count a self axe will it
always return 1?
For example:
count(self::*)
and
|
by: Regnab |
last post by:
The problem I'm having is the rsa.RecordCount always returns a '1' when
I know there should be about 1600 records returned. I read somewhere
that one should use '.MoveLast' before recordcount but...
|
by: Chris Lasher |
last post by:
Hi all,
How can one count all the permutations of a substring in a string? For
a more concrete example, let's say
targetstr = 'AAA'
and
probestr = 'AA'
I want to consider how many times one...
|
by: Advo |
last post by:
I've made a small search function as of here:
if (stristr($bleh,$search_for)) {
if(preg_match('/<title>(*)<\/title>/i', $bleh, $matches))
{
$name = str_replace("./","/",$name);
echo "<li><a...
|
by: trashman.horlicks |
last post by:
Hi,
I'm getting into a tangle with Regex in C#.
If I had an expression like abc.def.ghi etc.
How do I count how many instances there are of "" and "."
Thanks a lot!
TH
|
by: drasko |
last post by:
Hi, I have RegularExpressionValidator control and I wish to set it up
for limiting input text in textarea to 50 words. Users can enter text
they like, using all ".",",","!","?","@" and other...
|
by: jjjones3860 |
last post by:
I have XML like the following:
<book>
<title>
<author>
<book>
: : :
and so on for my example.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |