Join/Combine fields for a single search?
Posted: Tue May 13, 2003 5:29 pm
Is it possible to combine fields to apply a search to all of them as though they were one whole field?
I want to search fields for the same keywords, the user has the ability to apply an AND or an OR.
Take for example the field named Name and the field named Description. I want to combine Name and Description before applying the MySQL query on them, is this possible? Or am I "barking up the wrong tree" here?
I want to avoid the following code and just be able to use one LIKE command on a combined field. It's crucial that Melissa is found in CelebName and that Profession is found in CelebProfession, or that it be found in the Description as well, if it's an AND search, or hit at least one keyword if it's an OR search.
SELECT * FROM celebrity WHERE (CelebName LIKE '%melissa%' OR CelebName LIKE '%actress%') AND (CelebProfession LIKE '%melissa%' OR CelebProfession LIKE '%actress%') AND (Description LIKE '%melissa%' OR Description LIKE '%actress%') AND RecordStatus = 'A' ORDER BY CelebName LIMIT 0, 10
I want to search fields for the same keywords, the user has the ability to apply an AND or an OR.
Take for example the field named Name and the field named Description. I want to combine Name and Description before applying the MySQL query on them, is this possible? Or am I "barking up the wrong tree" here?
I want to avoid the following code and just be able to use one LIKE command on a combined field. It's crucial that Melissa is found in CelebName and that Profession is found in CelebProfession, or that it be found in the Description as well, if it's an AND search, or hit at least one keyword if it's an OR search.
SELECT * FROM celebrity WHERE (CelebName LIKE '%melissa%' OR CelebName LIKE '%actress%') AND (CelebProfession LIKE '%melissa%' OR CelebProfession LIKE '%actress%') AND (Description LIKE '%melissa%' OR Description LIKE '%actress%') AND RecordStatus = 'A' ORDER BY CelebName LIMIT 0, 10