Re: [PHP-DB] LIKE statement

2002-11-03 Thread Peter Beckman
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 BeckmanSystems Engineer, Fairfax Cable Access Corporation
[EMAIL PROTECTED] http://www.purplecow.com/
---


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] LIKE statement or IN statement?

2002-11-03 Thread Amit_Wadhwa
if you want to search for multiple words, u have to use multiple like
operators:
select count(distinct itemid) from business where name like 'word1' or
name like 'word2' or name like 'word3';

 or the IN statement with wildcards:
select count(distinct itemid) from business where name IN
('%word1%','%word2%','%word3%');  -- im not too sure of this, would the
experts please shed some more light on this one if its correct?

Amit

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 BeckmanSystems Engineer, Fairfax Cable Access
Corporation
[EMAIL PROTECTED]
http://www.purplecow.com/

---


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] LIKE statement or IN statement?

2002-11-03 Thread Chris Barnes
Yeah I really need to search for multiple words. Can anyone confirm if
the IN statement will work for me in this situation?

On Mon, 2002-11-04 at 09:31, [EMAIL PROTECTED] wrote:
 if you want to search for multiple words, u have to use multiple like
 operators:
 select count(distinct itemid) from business where name like 'word1' or
 name like 'word2' or name like 'word3';
 
  or the IN statement with wildcards:
 select count(distinct itemid) from business where name IN
 ('%word1%','%word2%','%word3%');  -- im not too sure of this, would the
 experts please shed some more light on this one if its correct?
 
 Amit
 
 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 BeckmanSystems Engineer, Fairfax Cable Access
 Corporation
 [EMAIL PROTECTED]
 http://www.purplecow.com/
 
 ---
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 




signature.asc
Description: This is a digitally signed message part


RE: [PHP-DB] LIKE statement or IN statement?

2002-11-03 Thread John W. Holmes
You can't use wildcards with IN, only with LIKE or regular expressions.

---John Holmes...

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:Amit_Wadhwa;Dell.com]
 Sent: Sunday, November 03, 2002 5:31 PM
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] LIKE statement or IN statement?
 
 if you want to search for multiple words, u have to use multiple like
 operators:
 select count(distinct itemid) from business where name like 'word1' or
 name like 'word2' or name like 'word3';
 
  or the IN statement with wildcards:
 select count(distinct itemid) from business where name IN
 ('%word1%','%word2%','%word3%');  -- im not too sure of this, would
the
 experts please shed some more light on this one if its correct?
 
 Amit
 
 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 BeckmanSystems Engineer, Fairfax Cable Access
 Corporation
 [EMAIL PROTECTED]
 http://www.purplecow.com/


 ---
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] LIKE statement or IN statement?

2002-11-03 Thread David Jackson
Chris Barnes wrote:

Yeah I really need to search for multiple words. Can anyone confirm if
the IN statement will work for me in this situation?

Chris --
Why not just try it you self and let's us know.
Also check to MySQL doc at http://mysql.org

David





On Mon, 2002-11-04 at 09:31, [EMAIL PROTECTED] wrote:


if you want to search for multiple words, u have to use multiple like
operators:
select count(distinct itemid) from business where name like 'word1' or
name like 'word2' or name like 'word3';

or the IN statement with wildcards:
select count(distinct itemid) from business where name IN
('%word1%','%word2%','%word3%');  -- im not too sure of this, would the
experts please shed some more light on this one if its correct?

Amit

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 BeckmanSystems Engineer, Fairfax Cable Access
Corporation
[EMAIL PROTECTED]
http://www.purplecow.com/

---


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php








--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] LIKE statement or IN statement?

2002-11-03 Thread Amit_Wadhwa
ok so you would have to use :
--select count(distinct itemid) from business where name like 'word1' or
name like 'word2' or name like 'word3';
no other go.




..
You can't use wildcards with IN, only with LIKE or regular expressions.

---John Holmes...

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:Amit_Wadhwa;Dell.com]
 Sent: Sunday, November 03, 2002 5:31 PM
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] LIKE statement or IN statement?
 
 if you want to search for multiple words, u have to use multiple like
 operators:
 select count(distinct itemid) from business where name like 'word1' or
 name like 'word2' or name like 'word3';
 
  or the IN statement with wildcards:
 select count(distinct itemid) from business where name IN
 ('%word1%','%word2%','%word3%');  -- im not too sure of this, would
the
 experts please shed some more light on this one if its correct?
 
 Amit
 
 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 BeckmanSystems Engineer, Fairfax Cable Access
 Corporation
 [EMAIL PROTECTED]
 http://www.purplecow.com/


 ---
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] LIKE statement or IN statement?

2002-11-03 Thread John W. Holmes
 ok so you would have to use :
 --select count(distinct itemid) from business where name like 'word1'
or
 name like 'word2' or name like 'word3';
 no other go.

If you're not going to use wildcards, then you can use IN. The whole
idea of using LIKE is that you can use _ and % as wildcards when
searching.

---John Holmes...



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php