sql query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gm000
    New Member
    • Nov 2009
    • 11

    sql query

    hi
    thanks for your reply i was very helpful for me regarding this i have a problem which is this

    i m using this query it works
    SELECT AuthorId, UrlUserName, Urlid, UrlAddress, ChooseMedia, Title, Description, ChooseThumbnail , ChooseTopic, Datetime,
    (SELECT COUNT(CommentId ) AS Expr1
    FROM CommentTable
    WHERE (CommentUrlid = Submitnewtable. Urlid)) AS cnt, DATEDIFF(second , Datetime, GETDATE()) AS diff
    FROM Submitnewtable
    WHERE (Title LIKE '%.com%')
    BUT I WANT TO USE A TEXTBOX.TEXT OR STRINGVARIABLE IN THE PLACE OF '%.com%' FOR SEACHING purpose
    i also used FREETEXT funciton for searching but it not working and give error which is fulltext index.My database table is not fulltext index enabled and i tried to enable fulltext index but i failed please guide me regarding above query


    thanks
  • nbiswas
    New Member
    • May 2009
    • 149

    #2
    Solution to SQL QUERY

    Hi, coming to ur doubts

    Q1) BUT I WANT TO USE A TEXTBOX.TEXT OR STRINGVARIABLE IN THE PLACE OF '%.com%' FOR SEACHING purpose

    Ans:

    Code:
    declare @p varchar(50)
    set @p = 'name'
    select * from MyTable where attribute like '%' + @p + '%'
    will give you the same result as

    Code:
    select * from MyTable where attribute like '%name%'
    You can use this in a stored proc or in inline query.

    So your query will be
    Code:
    WHERE (Title LIKE '%' + @var + '%') where @var will contain '.com'
    Q2) My database table is not fulltext index enabled and i tried to enable fulltext index.....

    Ans: Look into this

    Garuda138 adalah situs kasino dan slot online RTP Tinggi paling terkemuka di Indonesia yang menawarkan maxwin lebih mudah. Datang dan rasakan permainan online di sini dan Anda akan berkesempatan menerima banyak hadiah menarik.


    and this



    Hope this helps
    Last edited by nbiswas; Nov 11 '09, 02:51 AM. Reason: Added one more link for Setting Up Full Text Search

    Comment

    • gm000
      New Member
      • Nov 2009
      • 11

      #3
      hi
      still i have a confusion i m using this query in asp.vb page now i have
      Dim strsearch As String
      strsearch = txtsearch1.Text
      i want to search records form mytable with the value of strsearch
      strsearch is input valule for search a record form mytable
      please guide me about this

      dadsubmit = New SqlDataAdapter( "SELECT AuthorId, UrlUserName, Urlid, UrlAddress, ChooseMedia, Title, Description, ChooseThumbnail , ChooseTopic, Datetime, (SELECT COUNT(CommentId ) AS Expr1 FROM CommentTable WHERE (CommentUrlid = Submitnewtable. Urlid)) AS cnt,

      DATEDIFF(day, Datetime, GETDATE()) AS diff FROM Submitnewtable WHERE title like '%%' &strsearch , consumit)

      Comment

      Working...