0 Replies Latest reply on Sep 29, 2006 2:11 PM by Newsgroup_User

    MS-SQL - Like search form from a group of products.

    Level 7
      SELECT P.ID AS ProductID, P.Name, P.Price, P.ProdID, P.ShipCost,
      P.ClearSale, P.SalePrice, G.gid, G.pid AS Gpid, G.ord, PC.cid, PC.gid AS
      PCgid

      FROM atblProducts P INNER JOIN Groups G ON P.ID = G.pid INNER JOIN PCat
      PC ON G.gid = PC.gid
      WHERE (P.price IS NOT NULL AND PC.cid = 51 OR PC.cid = 52 OR PC.cid = 53
      OR PC.cid = 54) OR P.Name LIKE '%MMColParam3%' OR P.ID LIKE '%MMColParam3%'
      ORDER BY P.ProductID
      --------------------------------------------------
      WHERE P.Price IS NOT NULL AND PC.cid = 51 OR PC.cid = 52 OR PC.cid = 53
      OR PC.cid = 54

      This gives me the group of products that I need but as soon as I add the
      '%MMColParam3%' bit to see the items searched on, it fails.

      What I am doing is pulling in the '%MMColParam3%' using a form to check the
      product name, and the description out of a group of 4 categories: 51, 52,
      53, 54. I can get the 4 categories to display but as soon as I add the OR
      P.Name LIKE '%MMColParam3%' OR P.ID LIKE '%MMColParam3%'
      bit, it fails.