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


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))

Updated on: 25-Jun-2020

82 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements