I think I didn't formulate my question right.The proposed qry returns me the first x id's with their matched keyword count (where x is the number of keywords in the keywords table)Take the next situation:@KeyWordsid word-- ----1 merc2 redselect ps.id, ps.value, ps.source, ps.colorId, k.wordfrom powersearch psinner join @keywords kon ps.value like '%'+k.word+'%'id value src colorId word------- ------------------------- ----- ------ ----1633461 MERCEDES CO 157323 merc1635581 COMMERCIAL TRANSPORT AUST CO 508802 merc1635583 COMMERCIAL TRANSPORT AUST CO 308795 merc...1884471 KAIXUAN/VICTORY RED CLR_NM 508802 red1884475 RUTLAND RED CLR_NM 508806 red
Now I only need the rows with colorId 508802 because it has at least 1 entry for both keywords.