Google Answers Logo
View Question
 
Q: Full Search in MySql ( No Answer,   0 Comments )
Question  
Subject: Full Search in MySql
Category: Computers > Programming
Asked by: shantanuo-ga
List Price: $10.00
Posted: 31 Mar 2003 04:18 PST
Expires: 17 Apr 2003 05:45 PDT
Question ID: 183595
Hi,
 
Is there any way to do full search on one of the tables?
1. I have a table of contacts. 
2. I am looking for the word "shah".
3. It may be in Surname or address column. 
4. I can't specify the column headings as well.
5. Is it possible to search for the word "shah" anywhere in the table?

I thought the following code would be useful to me.

http://aspn.activestate.com/ASPN/Cookbook/PHP/Recipe/125901

I have tried printing the results with print_r along
the following code mentioned on the page,

$mysearch = new MysqlSearch;
$mysearch->setidentifier("MyPrimaryKey");
$mysearch->settable("MyTable");
$results_array = $mysearch->find($mysearchterms);

I am getting the text array() as a result.

Shantanu Oak

Request for Question Clarification by super-ga on 01 Apr 2003 10:43 PST
Hi,

The above script returns an array with primary keys. These primary
keys correspond to the rows that contain your word.
So if you only want the first result do $results_array[0].
You can also parse that array and get all the results.

If you know the colums you are searching in you can simply do:
SELECT col1, col2 FROM your_table WHERE col1 LIKE '%text%' OR col2
LIKE '%text%'

Give me more details and I will try to better answer your question.

Thank you.

Clarification of Question by shantanuo-ga on 01 Apr 2003 18:00 PST
Hi,
(1)
Please visit
https://www.quickbase.com/db/7ha7wpd4
and type "shah" in the find box to get the rows those contain the
word.
I want to do this with mysql.

(2)
> If you know the colums you are searching in you can simply do: 
> SELECT col1, col2 FROM your_table WHERE col1 LIKE '%text%' OR col2
> LIKE '%text%'
I want to write a class that can be used with other tables as well and
not only with contacts table.

(3)
I asked this question on php-db list.
Here is what some of the experts came up with...

Or use mysql dump and search for the value in text pad. - Mike
Karthauser

you can't... if you want to find greg.. you have to specify that you
want to find greg... hence the Surname= part...  Jay

It seems that phpmyadmin does not have this function.

I hope now I have made it clear what I am looking for.

Shantanu Oak

Request for Question Clarification by super-ga on 01 Apr 2003 19:59 PST
Hi again,

Let me see if i understand this correctly.

You need a class that takes as arguments a table and a search string
and returns the rows where the string appears.

If this is correct then the class you presented before should do the
job.
To properly display the results you can:
- either modify the above class to save the information of the fields
where the string has been found
- or after the class returns the index array loop through that array
and select for each index the corresponding row and display it.

The way i would to this though would be to create a dynamic sql
statement of the form "SELECT col1, col2 FROM your_table WHERE col1
LIKE '%text%' OR col2 LIKE '%text%".

For this the class would take as input a table and a search string.
to do this:
- get the column names for the table - use mysql_field_name
- construct your query 
- do the query, get and display the data

There is an interesting example at 
http://www.php.net/manual/en/function.mysql-field-name.php
in the User Contributed Notes, look for the note dated on 20-Feb-2003.

If you expect a complete solution I would humbly suggest that you
raise up the List Price.

I hope it helps.

Thank you.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy