Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Imagine I have this table named test_table in the test_db in MySQL:

field1     field2  
google   http://google.com  
apple    http://apple.com  
python   http://python.org   

Now if I search the database using this:

SELECT * FROM test_table WHERE field1 = "google"; 

It will return : http://google.com
Now I want to search the database with field1 and return field2 value where field1 like to search keyword.
For example if I give it googles it should return : http://google.com
How can I do this?

share|improve this question
    
You're asking for something like a soundex query, but unfortunately it's not. What you're asking for is beyond the reach of this site. How would I know that "googles" is "google.com" and not something else? Is there a lookup table for spelling mistakes that map to the real strings? –  FreshPhilOfSO Jan 22 '13 at 22:40
    
or perhaps a FTS that uses a stemmer of some sort (Lucene?) ... or a natural language stemmer to preparse the query. –  swasheck Jan 22 '13 at 22:41
1  
Perhaps you mean this?: SELECT field2 FROM test_table WHERE 'googles' LIKE CONCAT( '%', field1, '%' ); –  ypercube Jan 22 '13 at 22:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.