我想要做这样的事情:在Delphi 7中,如何在Format函数中转义百分号(%)?
SQL.Text := Format('select foo from bar where baz like ''%s%''',[SearchTerm]);
但格式不喜欢,去年“%”,当然。那么我怎么能逃脱它? \%
? %%
?
还是我必须这样做:
SQL.Text := Format('select foo from bar where baz like ''%s''',[SearchTerm+'%']);
?
注意,你应该更好地使用参数查询,或至少在处理引号的SearchTerm(例如,通过QuotedStr()调用)。 – 2012-09-06 09:29:35