Search From Different Tables
Posted: Mon May 11, 2009 2:59 am
I have 2 fields, Keywords & Type. I have to search from 2 different tables knb_faq & knb_solution as per the keywords & type.
Here is my mysql query :
There is no error msg but my problem is that for this query I am not getting result perfectly. The search is occured but it is not searching from both the tables according to Keyword & Type.
Is there any wrong in the sql query? If so, Please tell me the right syntax.
Here is my mysql query :
Code: Select all
$keyword=$_GET['keyword'];
$type=$_GET['type'];
$srch=mysql_query("select knb_faq.*,knb_solution.* from knb_faq,knb_solution where (knb_faq.solution LIKE '%$keyword%' or knb_faq.keywords LIKE '%$keyword%' or knb_faq.subject LIKE '%$keyword%'and knb_faq.type='$type') or
(knb_solution.solution LIKE '%$keyword%' or knb_solution.keywords LIKE '%$keyword%' or knb_faq.solution LIKE '%$keyword%' and knb_solution.type='$type')") or die (mysql_error());
Is there any wrong in the sql query? If so, Please tell me the right syntax.