Re: [PHP] better functionality in query ?
On Friday 06 April 2001 01:57, you wrote: NOTE(!): LIKE '%foo%' DOES NOT SCALE. It looks like you are making a phone book, which could get to be a lot of numbers. On the other hand 'foo%' oddly scales to hundreds of thousands of records without any problems (make sure it's key'd!). Well, if you think a bit about it it's not odd at all. For "%foo%" the DB has to examine the entire string until it finds an occurence of "foo" or until it reaches the end - and it can not use any (normal) index. for it. For "foo%" it just has to examine the first three chars - that's even faster than "WHERE phone = 'foobar-something'" and works very nicely with a perfectly normal index. -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) I saw God - and she was black. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] better functionality in query ?
I'm in process of creating a online whitepages directory for a small town phone company and I am having a little difficulty in refining my selection. My search form has two fields; last and first name. I would like to be able to have more of a wild card approach and some refinement when a user enters both a first and last name. I am unsure how to go about this, should I restructure my query, or make changes to my PHP. here is the query I am currently using. and the site is located at http://whitepages.maadtelco.com/ any assistance/direction is certainly appreciated. snip $query = "select * from whitepages WHERE last_name LIKE '$last_name' ORDER BY last_name" or die("Nothing to see here"); /snip Jerry Lake- [EMAIL PROTECTED] Web Designer Europa Communications - http://www.europa.com Pacifier Online - http://www.pacifier.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] better functionality in query ?
I'm in process of creating a online whitepages directory for a small town phone company and I am having a little difficulty in refining my selection. My search form has two fields; last and first name. I would like to be able to have more of a wild card approach and some refinement when a user enters both a first and last name. I am unsure how to go about this, should I restructure my query, or make changes to my PHP. here is the query I am currently using. and the site is located at http://whitepages.maadtelco.com/ any assistance/direction is certainly appreciated. snip $query = "select * from whitepages WHERE last_name LIKE '$last_name' ORDER BY last_name" or die("Nothing to see here"); /snip $query = "SELECT * FROM whitepages WHERE last_name LIKE '%$last_name%' ORDER BY last_name" or die("Nothing to see here"); Question, why are you 'die'ing on a variable assigntment? Wouldn't you want to 'die' on the actualy db_query()? Note the added '%', this is assuming you are using MySQL, though they are generally the same, I believe, with other DB's. The % is essentially wildcard of any amount. So, if the last_name was BOB it would find BOBBY BOBBER ADOBOB $query = "SELECT * FROM whitepages WHERE last_name LIKE '%$last_name%' $andor first_name LIKE '%$first_name' ORDER BY last_name" or die("Nothing to see here"); In this query, we are including the First Name. In this, we are also using the $andor variable, which you can define as AND, or OR, or allow the user to define it by using a radio box or the like when making the search. I suggest setting a default of OR for the variable $andor. Jason Lotito www.NewbieNetwork.net Where those who can, teach; and those who can, learn. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] better functionality in query ?
Damn, if I'd a known it was that easy ;) Thanks for the help, works great now. Jerry Lake- [EMAIL PROTECTED] Web Designer Europa Communications - http://www.europa.com Pacifier Online - http://www.pacifier.com -Original Message- From: Jason Lotito [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 05, 2001 7:09 PM To: Jerry Lake; [EMAIL PROTECTED] Subject: RE: [PHP] better functionality in query ? I'm in process of creating a online whitepages directory for a small town phone company and I am having a little difficulty in refining my selection. My search form has two fields; last and first name. I would like to be able to have more of a wild card approach and some refinement when a user enters both a first and last name. I am unsure how to go about this, should I restructure my query, or make changes to my PHP. here is the query I am currently using. and the site is located at http://whitepages.maadtelco.com/ any assistance/direction is certainly appreciated. snip $query = "select * from whitepages WHERE last_name LIKE '$last_name' ORDER BY last_name" or die("Nothing to see here"); /snip $query = "SELECT * FROM whitepages WHERE last_name LIKE '%$last_name%' ORDER BY last_name" or die("Nothing to see here"); Question, why are you 'die'ing on a variable assigntment? Wouldn't you want to 'die' on the actualy db_query()? Note the added '%', this is assuming you are using MySQL, though they are generally the same, I believe, with other DB's. The % is essentially wildcard of any amount. So, if the last_name was BOB it would find BOBBY BOBBER ADOBOB $query = "SELECT * FROM whitepages WHERE last_name LIKE '%$last_name%' $andor first_name LIKE '%$first_name' ORDER BY last_name" or die("Nothing to see here"); In this query, we are including the First Name. In this, we are also using the $andor variable, which you can define as AND, or OR, or allow the user to define it by using a radio box or the like when making the search. I suggest setting a default of OR for the variable $andor. Jason Lotito www.NewbieNetwork.net Where those who can, teach; and those who can, learn. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] better functionality in query ?
NOTE(!): LIKE '%foo%' DOES NOT SCALE. It looks like you are making a phone book, which could get to be a lot of numbers. On the other hand 'foo%' oddly scales to hundreds of thousands of records without any problems (make sure it's key'd!). Which should work fine in your instance - just have people type in the first 4 letters of the persons name. --Joe On Thu, Apr 05, 2001 at 04:51:47PM -0700, Jerry Lake wrote: Damn, if I'd a known it was that easy ;) Thanks for the help, works great now. Jerry Lake- [EMAIL PROTECTED] Web Designer Europa Communications - http://www.europa.com Pacifier Online - http://www.pacifier.com -Original Message- From: Jason Lotito [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 05, 2001 7:09 PM To: Jerry Lake; [EMAIL PROTECTED] Subject: RE: [PHP] better functionality in query ? I'm in process of creating a online whitepages directory for a small town phone company and I am having a little difficulty in refining my selection. My search form has two fields; last and first name. I would like to be able to have more of a wild card approach and some refinement when a user enters both a first and last name. I am unsure how to go about this, should I restructure my query, or make changes to my PHP. here is the query I am currently using. and the site is located at http://whitepages.maadtelco.com/ any assistance/direction is certainly appreciated. snip $query = "select * from whitepages WHERE last_name LIKE '$last_name' ORDER BY last_name" or die("Nothing to see here"); /snip $query = "SELECT * FROM whitepages WHERE last_name LIKE '%$last_name%' ORDER BY last_name" or die("Nothing to see here"); Question, why are you 'die'ing on a variable assigntment? Wouldn't you want to 'die' on the actualy db_query()? Note the added '%', this is assuming you are using MySQL, though they are generally the same, I believe, with other DB's. The % is essentially wildcard of any amount. So, if the last_name was BOB it would find BOBBY BOBBER ADOBOB $query = "SELECT * FROM whitepages WHERE last_name LIKE '%$last_name%' $andor first_name LIKE '%$first_name' ORDER BY last_name" or die("Nothing to see here"); In this query, we are including the First Name. In this, we are also using the $andor variable, which you can define as AND, or OR, or allow the user to define it by using a radio box or the like when making the search. I suggest setting a default of OR for the variable $andor. Jason Lotito www.NewbieNetwork.net Where those who can, teach; and those who can, learn. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] /**\ *Joe Stump - PHP/SQL/HTML Developer * * http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net * * "Better to double your money on mediocrity than lose it all on a dream." * \**/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] better functionality in query ?
I'm in process of creating a online whitepages directory for a small town phone company and I am having a little difficulty in refining my selection. My search form has two fields; last and first name. I would like to be able to have more of a wild card approach and some refinement when a user enters both a first and last name. I am unsure how to go about this, should I restructure my query, or make changes to my PHP. here is the query I am currently using. and the site is located at http://whitepages.maadtelco.com/ any assistance/direction is certainly appreciated. snip $query = "select * from whitepages WHERE last_name LIKE '$last_name' ORDER BY last_name" or die("Nothing to see here"); /snip $query = "SELECT * FROM whitepages WHERE last_name LIKE '%$last_name%' ORDER BY last_name" or die("Nothing to see here"); Question, why are you 'die'ing on a variable assigntment? Wouldn't you want to 'die' on the actualy db_query()? Note the added '%', this is assuming you are using MySQL, though they are generally the same, I believe, with other DB's. The % is essentially wildcard of any amount. So, if the last_name was BOB it would find BOBBY BOBBER ADOBOB $query = "SELECT * FROM whitepages WHERE last_name LIKE '%$last_name%' $andor first_name LIKE '%$first_name' ORDER BY last_name" or die("Nothing to see here"); In this query, we are including the First Name. In this, we are also using the $andor variable, which you can define as AND, or OR, or allow the user to define it by using a radio box or the like when making the search. I suggest setting a default of OR for the variable $andor. Jason Lotito On Thu, Apr 05, 2001 at 04:51:47PM -0700, Jerry Lake wrote: Damn, if I'd a known it was that easy ;) Thanks for the help, works great now. -Original Message- From: Joe Stump [mailto:[EMAIL PROTECTED]] NOTE(!): LIKE '%foo%' DOES NOT SCALE. It looks like you are making a phone book, which could get to be a lot of numbers. On the other hand 'foo%' oddly scales to hundreds of thousands of records without any problems (make sure it's key'd!). Which should work fine in your instance - just have people type in the first 4 letters of the persons name. --Joe Very true, good point. Good thing to keep in mind, and something I overlooked. Jason Lotito www.NewbieNetwork.net Where those who can, teach; and those who can, learn. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]