Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Jeff Styles2,784 Points
Is there a shorter way to write a condition such as "where id = 8 or id = 9 or id = 16"?
Suppose there are many rows to update and "between" isn't an option since they aren't blocked together in numerical order. Is there a way to shorten this, along the lines of: "where id = 8, 9, or 16" ? Thanks.
in operator might be what you are looking for. It allows you to specify a comma separated list of values within parenthesis that are checked against the thing you are comparing. For example your query using an
in operator would look like this:
where id in (8, 9, 16)