سؤال

I have a query which uses IN clause and it is not working for below case:

Select *   
from table1   
where   
Rollno || '/' || UserId IN ('1/001,2/002')  
هل كانت مفيدة؟

المحلول

It is not working because you haven't wrapped each value in single quotes ' :

SELECT *   
FROM table1   
WHERE  Rollno || '/' || UserId IN ('1/001','2/002')  

نصائح أخرى

Notulysses has the right syntax for in. But, if you have to deal with a string, you can rephrase this as like:

where ',' || Rollno || '/' || UserId || ',' like '%,' || '1/001,2/002' || ',%'

like is a better approach. Sometimes in the real world, you might have to deal with comma-delimited strings.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top