0

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;"

Edited by hwoarang69

2
Contributors
1
Reply
19
Views
1 Year
Discussion Span
Last Post by incomer
0

I'm no vb.net programmer, but...
did you try:

Dim mkey As String = "ra"
Dim astChar As String = "*"
Dim query As String = "SELECT DISTINCT a.[rank], b.Description
   FROM CONTAINSTABLE(myTable, *, '" & mKey & astChar & "') AS a
       INNER JOIN myTable AS b ON a[key] = b.ID
           ORDER BY a.rank desc;"

Sorry if I didn't get the quotes completely correct.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.