Home Forums SQL Server 7,2000 General How to write SQL query to find a word in string" RE: How to write SQL query to find a word in string"

  • Hi Dugi, thanks for the quick reply. Here is the vb code that do this search. Isn't that same as yours?

    Public Function Search_Related_Videos(ByVal search As String) As DataSet

    Dim Query As String = "SELECT TOP 20 * FROM Videos WHERE isEnabled=1 AND isPrivate=0"

    If Not search = "all" Then

    Query = Query & " AND"

    End If

    If Not search = "all" Then

    Query = Query & " (title like '%" & search & "%'"

    Query = Query & " OR description like '%" & search & "%'"

    Query = Query & " OR tags like '%" & search & "%')"

    End If

    '// Order by clause

    Query = Query & " ORDER BY date_added DESC"

    Return SqlHelper.ExecuteDataset(_constring, CommandType.Text, Query)

    End Function