SQL Apprentice Question
Is it okay to use a literal value with the IN clause. E.g.
SELECT somefield, anotherfield
....
WHERE ...etc.
AND 1234 IN (SELECT userid FROM tblUsers)
I was told it wasn't valid, but I'm pretty sure it worked for me. Just
seeking clarification.
Celko Answers
It is valid, Standard SQL and can be a useful trick to avoid OR-ed
predicates. The IN() list just has to be expressions that will cast
to the proper data type.
Thursday, April 13, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment