Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How to replace string with variable in substring?

sql

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 game2d

game2d

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 57 posts

Posted 08 November 2015 - 05:20 PM

How to replace string with variable in substring? btw im using vb
 
I have a below query that work fine but I just want to replace "ra*" with a variable. How can I do this?
 
SELECT DISTINCT a.[rank], b.Description
    FROM CONTAINSTABLE(myTable, *, '"ra*'") AS a
        INNER JOIN myTable AS b ON a[key] = b.ID
             ORDER BY a.rank desc;
 
Below is what I tried so far but it doesnt work. it treat as '"ra"' and not '"ra*"'. Any idea how can I fix this?
 
Dim mkey As String = "ra"
Dim query As String = "SELECT DISTINCT a.[rank], b.Description
        FROM CONTAINSTABLE(myTable, *, '" & mKey & "*') AS a
            INNER JOIN myTable AS b ON a[key] = b.ID
                ORDER BY a.rank desc;"