Search code examples
sqlstringreporting-servicesinner-joinsql-like

How to match partial strings in one table to ID in another table?


I need to find a way to be able to find out who viewed, shared and downloaded a document.

I need to figure out a way to match the ID of the file in the string in the logDetail table to the documentID in another table, so i can match the files/document names to those ids.

Below shows part of my tables.

logDetail enter image description here

documents

enter image description here


Solution

  • Hmmm . . . You could do something like this:

    select ld.*
    from logDetail ld join
         documents d
         on ld.logDetail like concat('% ID ', d.documentId);
    

    All the logDetail records that you show end with ' ID <number>', so this matches on that pattern.