title: T-SQL How to Match Multiple Rows
body: <p>There are two tables, package table and product table. In my case, the package contains multiple products. We need to recognize multiple products whether they can match a package which is already in package records. Some scripts are below.</p>
  
  <pre><code>DECLARE @tblPackage TABLE(
      PackageID   int,
      ProductID   int
  )
  
  INSERT INTO @tblPackage VALUES(436, 4313)
  INSERT INTO @tblPackage VALUES(436, 4305)
  INSERT INTO @tblPackage VALUES(436, 4986)
  
  INSERT INTO @tblPackage VALUES(437, 4313)
  INSERT INTO @tblPackage VALUES(437, 4305)
  
  INSERT INTO @tblPackage VALUES(442, 4313)
  INSERT INTO @tblPackage VALUES(442, 4335)
  
  INSERT INTO @tblPackage VALUES(445, 4305)
  INSERT INTO @tblPackage VALUES(445, 4335)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/5odQg.png" alt="enter image description here"></p>
  
  <pre><code>DECLARE @tblProduct TABLE(
      ProductID   int
  )
  
  INSERT INTO @tblProduct VALUES(4305) 
  INSERT INTO @tblProduct VALUES(4313)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ANJ0G.png" alt="enter image description here"></p>
  
  <p>We have two product 4305 and 4313, then I need to retrieve the matched package record 437. Only the exactly matched one can be return, so package 436 is not the right one. It's not easy to make a multiple rows query clause. please someone can have any suggestions? Thanks.</p>