Jump to content

Recommended Posts

"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!

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.