Search by "AND"....
| From: | Koo | Date: | Wed, 13 Dec 2000 07:13:47 +0000 |
| Subject: | Search by "AND".... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-30051@lists.php.net to get a copy of this message | ||
I got two typical MySQL tables for fulltext search:
table1 table2
------ ------
wordID wordID
itemID word
where "word" holds all words
------------------------------------------------------
When I try to query the database for any items with
EITHER wordA OR wordB, I do the following:
mysql> select itemID from table1,table2
where table1.wordID=table2.wordID
and (word like '%wordA%' or word like '%wordB%');
It works.
But when I want query for any items which contain BOTH
wordA AND wordB, the following query always outputs 0 rows.
mysql> select itemID from table1,table2
where table1.wordID=table2.wordID
and (word like '%wordA%' and word like '%wordB%');
Why? And what's the simplest way to accomplish my task?
Many thanks.