java - SQL selecting all records with IN statement -
in case, first 2 parameters mandatory. when users hasn't given rest of parameters, i'm using charachter '%' statement data shown. idea how solve in statement? solution param in ('%') not working => null
parameters:
java.sql.timestamp, java.sql.timestamp, java.lang.string, java.lang.string, java.lang.string, java.lang.string
query:
select * rc_recall t inner join rc_recallstore s on t.id = s.recallid t.creationdate >= ?1 , t.enddate <= ?2 , t.id ?3 , t.afdeling in (?4) , s.storeid in (?5) order id desc
the in statement in sql cannot accept wild card character. have add or query work...
select * rc_recall t inner join rc_recallstore s on t.id = s.recallid t.creationdate >= ?1 , t.enddate <= ?2 , t.id ?3 , ('%' = ?4 or t.afdeling in (?4)) , ('%' = ?5 or s.storeid in (?5)) order id desc
if you're using parameter position pass parameters, you'll have change
and ('%' = ?4 or t.afdeling in (?5)) , ('%' = ?6 or s.storeid in (?7))
hope helps
Comments
Post a Comment