Hi.
I'm currently building a search routine for a clip art website in PERL using MySQL. I have extracted all title words, and all clip tags associated with all clips into a table. I've extracted a selection and the table format and attached.
I'd like to build an SQL query which will interrogate this one table but the number of querries involved is making it extremely difficult and complex. Too complex for me to do efficently and correctly.
In Perl I'm stripping all the useless words and extracting the core search words like so.
$search_value =~ s/'/\\'/g;
use Lingua::StopWords qw( getStopWords );
my $stopwords = getStopWords('en');
@words = split(/ /, $search_value);
What I need to achieve is to search the table based on the following criteria and in the following order.
As an example let us use the Search Phrase (Green Globe)>
I need the SQL to
1. Search the table for the phrase "Green Globe" (case insensitive) from field search_word where title_word = 'Y' and Product_publish = 'Y'
2. Search the table for the phrase "Green Globe" (case insensitive) from field_search_word where title_word = 'N' and Product_publish = 'Y'
3. Search the table for the word "Green" (case insensitive) from field_search and Product_publish = 'Y'
4. Search the table for the word "Globe" (case insensitive) from field_search and Product_publish = 'Y'
5. As product_id is a many to one ... this field needs to be grouped.
I will also need to use some form of a join to link to the actual product table to get the full details, but I think I can do this.
As the results need to be split over various pages, I need to get a count of the number of returned records and work out the number of page results. Again I believe I can do this based on the final SQL.
If somebody can get me started on the SQL it would be appreciated. What would be nice would be if the SQL statement could also display a result if the one of the keywords/phrases (search_word) was for example greenish globe.
Mysql Version is : 5.0.81-community
Architecture is : i686
Apache version 2.0.63
Perl: 5.8.8
Many thanks for reading this.
Cormac