Using “like” wildcard in
prepared statement
Query : SELECT
COUNT(o.orders_id) AS orders,ROUND(SUM(o.totalproduct),0) AS
ordersum,ROUND(AVG(o.totalproduct),0) AS orderavg FROM orders o, users usr
WHERE o.member_id=usr.users_id and
o.timeplaced like ? and usr.field1='IU' and o.status='M'
In Java:
String mmSearch =
"%";
Set<String> keys =
previousOrdersDateMap.keySet();
for(String key: keys){
if(null
!= key){
key = mmSearch+key+mmSearch;
PreparedStatement
preparedStatement = conn.prepareStatement(detQryType);
preparedStatement.setString(1,key);
No comments:
Post a Comment