#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    95
    Rep Power
    3

    Using a variable in a like


    Hi,
    Your'e probably not really supposed to do this kind of thing, but i'm trying to write a query that uses a set variable in a LIKE
    SET @var=91; SELECT blockednumber, blockgroup FROM blocks WHERE blockenumber LIKE '@var%'
    this provides no results. any ideas?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    Paris Uppland
    Posts
    2,385
    Rep Power
    391
    Code:
    select blockednumber,
           blockgroup
      from blocks
     where blockednumber like concat(@var,'%')
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    95
    Rep Power
    3
    works! thank you very much.

IMN logo majestic logo threadwatch logo seochat tools logo