search Text area boxes is it possible

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

search Text area boxes is it possible

Post by mohson »

Normally when I search for a record I simply search a field that contains a single value - like so:

Code: Select all

foreach($HTTP_POST_VARS as $varname => $value)
        $formVars[$varname]=$value;

 $query = 	"SELECT 
		 orgname, web_url,sector,org_id,person_id, 
		 notes 
		 
		 FROM organisations 
		 

		WHERE orgname LIKE '$formVars[orgname]%'";
But I am planning on using some large text areas to make genereal notes, I understand that the data will still be inserted into a normal field BUT

How difficult will it be to search for any text in this field, when I say 'any text' I mean any word,number,value which is stored in the fiield.

Maybe I am making this more complex than what it is. Please advise
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

From looking at some of the articles, this seems to be refering to indexing and speeding up your searches.

What I am asking is , from your experience (or anyone elses) if they have a field which contains more than one item of data (perhaps quite a bit more) is it possible / have you searched for any of the items in that field

Example

Filed = Notes

values = Person x worked for us in 2007, he then went on to work for company x etc etc


Would it then be possible to run a query where you search for the value 'person x ' or 'company x' from this field.

The values 'person x' and 'company x' as well as others could be anything so the key search will be the word the user inputs in the search box.

Have you done this before, would it be sone similar to the search quesry I run in my original post?

Thanks
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

...which is EXACTLY what FULLTEXT searching is.

Read the links again
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

i.e. If you had a table with a list of names.

Create a FULLTEXT index on the name field

then your query would look like this

Code: Select all

SELECT * FROM `users` WHERE MATCH(`name`) AGAINST('yourSearchCriteria' IN BOOLEAN MODE)
Post Reply