stig1 Posted January 14, 2009 Share Posted January 14, 2009 "select tbl_prod.prodID, tbl_prod.itmClass, tbl_prod.prodName, tbl_prod.prodDesc, tbl_prod.prodImg from tbl_prod, tbl_prod_items where tbl_prod.prodName like '%".$qsearch."%' or tbl_prod.prodDesc like '%".$qsearch."%' or tbl_prod_items.itmDesc like '%".$qsearch."%' and tbl_prod.prodHide is null order by tbl_prod.prodName asc" $qsearch = the search term a customer enters in. The join I require is to find the search term in either table but no duplicate results. I have to fields that should join, however they are varchar(20) fields. tbl_prod.itmClass and tbl_prod_items.itmClass is a 1 to many relationship. If i put the value 80mm in the search box, I should be able to retrieve all the values related to 80mm. How do I go about making this join with the where statement? Cause it doesnt seem to be working for me! Link to comment https://forums.phpfreaks.com/topic/140871-trouble-using-joins-with-where-statement/ Share on other sites More sharing options...
fenway Posted January 18, 2009 Share Posted January 18, 2009 Well, you're also missing parens for your OR conditions! select tbl_prod.prodID, tbl_prod.itmClass, tbl_prod.prodName, tbl_prod.prodDesc, tbl_prod.prodImg from tbl_prod tbl_prod_items using( itemClass ) where ( tbl_prod.prodName like '%".$qsearch."%' or tbl_prod.prodDesc like '%".$qsearch."%' or tbl_prod_items.itmDesc like '%".$qsearch."%' ) and tbl_prod.prodHide is null order by tbl_prod.prodName asc Link to comment https://forums.phpfreaks.com/topic/140871-trouble-using-joins-with-where-statement/#findComment-739722 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.