戰地連結︰ Home My Flickr NBA.com About

2008年10月7日星期二

Using parameter with Microsoft Query 'CONTAINS' criteria

Overview

Microsoft Query does provide the "CONTAINS" criteria to check whether a field contains a value, the SQL 'WHERE' clause for this is "WHERE criteria_field LIKE '%value_to_check%'". The problem is how to use parameter with "CONTAINS" criteria?

Steps

With the '&' operator we can easily concatenate the parameter in the "LIKE '%%'" clause. The SQL is:
WHERE criteria_field LIKE '%' & ? &'%'

沒有留言: