IN statement in SQL doesn’t accept a wild character (SAP)

SQLSAP HANASAPSAP Basis

Note that IN statement in SQL doesn’t accept a wild character. You have to use OR/AND to make it work as mentioned below:

select *
from Test1 t INNER JOIN Test2 s ON t.ID = s.RID
where t.sdate >= ?1
AND t.edate <= ?2
AND t.id LIKE ?3
AND ('%' = ?4 OR t.afdeling IN (?4))
AND ('%' = ?5 OR s.sid IN (?5))
ORDER BY ID DESC

In case you are using parameter position to pass parameters, try changing it as below:

AND ('%' = ?4 OR t.afdeling IN (?5))
AND ('%' = ?6 OR s.sid IN (?7))
raja
Published on 06-Dec-2017 20:19:04
Advertisements