Re: LIKE statement
| From: | Peter Beckman | Date: | Sun, 03 Nov 2002 19:02:30 +0000 |
| Subject: | Re: LIKE statement | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-22930@lists.php.net to get a copy of this message | ||
change your query to this:
select count(distinct itemid) from business where name like 'word1 word2
word3%' or description like 'word1 word2 word3%';
Peter
On 4 Nov 2002, Chris Barnes wrote:
> Hi,
> I've got a dilly of a problem. I'm probably doing something wrong but I
> don't know what. I'm trying to use the LIKE statement in a query where
> more than one word is used in with LIKE..e.g.
>
> select count(distinct itemid) from business where name or description
> like 'word1 word2 word3%'
>
> The problem I'm having is probably obvious to you but I don't know why
> this returns no matches but if i specify only 1 word in the LIKE
> statement then it returns a match.
>
> Am i not able to specify more than 1 word with LIKE or am I just doing
> it wrong?
>
> It has been designed to take input from a web form by the variable
> $search_string and then the query string is constructed from that e.g.
>
> $query = "select count(distinct itemid) from business where name or
> description like'" . $search_string . "'";
>
>
> Any help or suggestions greatly appreciated.
>
---------------------------------------------------------------------------
Peter Beckman Systems Engineer, Fairfax Cable Access Corporation
beckman@purplecow.com http://www.purplecow.com/
---------------------------------------------------------------------------