Brad McCormick


Good Morning Everyone,

Quick question, how can i use a variable with a like statement as in
select * from table where col1 like var



Re: Qick Sql question

Naomi Nosonovsky


Try

select * from table where col1 like m.lcVar + "*"

assuming that col1 is character and you want to find records starting with what lcVar variable contains.






Re: Qick Sql question

Brad McCormick

Well that didnt quite work but i used

select * from table where col1 like m.lcVar + "%"

which is maybe what you meant to put.

Thanks though i appreciate it





Re: Qick Sql question

Naomi Nosonovsky

Yes, that's exactly what I meant. I guess I put * by mistake, I actually even tried a test just in case before replying using %

Sorry for the typo.





Re: Qick Sql question

CetinBasoz

select * from myTable where col1 like m.var + '%'

If you're doing this against a VFP table and ANSI is off (default setting):

select * from myTable where col1 = m.var

has the same effect.