Can I use an expression as input to 'Like'?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BTL1437
    New Member
    • Dec 2013
    • 1

    Can I use an expression as input to 'Like'?

    First, I am a totel novice, so I apologize if I use the wrong terminology. I am writing a simple query and want to use the 'Like' function to select only record that contain a certain string. When I use: Like "*Aerospace *" it works perfectly, but when I use: Like "*&[Expr1]&*" it doesn't work at all, even though Expr1 is equal to Aerospace. What am I missing?
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    You would need to to be
    Code:
    '*' & [Expr1] & '*'
    Otherwise, your Expr1 is inside the quotes and it is taken for a literal string instead of like a variable that should be replaced by Aerospace.

    Comment

    Working...