Forum Moderators: open
This is my search query
"SELECT * FROM Product, Picture, CategoryProduct WHERE CategoryProduct.Enabled = 1 AND CategoryProduct.ProductID = Product.ProductID AND ((Product.Title LIKE '$srch') ¦¦ (Product.ShortDescription LIKE '$srch')) AND Picture.EntityID = Product.ProductID"; Every now and then I get duplicate results when the search is returned. It doesn't happen with every search just certain ones. I have checked the database and the products which are duplicates do not appear twice in the table. What causes this to happen? (I am using if(number of row >=1 ){do{results}while()} )
And also, I am a greenie at this, so looking at my query, is it done in the most efficient manner?
tblCategoryProduct is only used to check if the product is enabled. tblProduct contains all the product info, of course and tblPicture contains the urls to the images, if that information helps at all.
I appreciate any insight anyone may have.
Thanks for your time and I apologize if this is quite elementary.
Chris
most likely you are getting duplicates from a join that you are missing. in your WHERE clause, you might need to specify another match or two to make sure you are getting unique records.
if it's possible to get more than one result, you could look into the DISTINCT parameter after SELECT, which will only bring back unique records.