Introduction

This tutorial will teach you how to use the SQL IN Command. The SQL IN Command can be used to filter results returned by a Query. It is very simple to use and to add on to an existing Query and it takes hardly any time at all.

Step 1. The IN Command

1. The IN Command can be used to filter query results, but it requires the use of the WHERE Command in order to work. For Example:

This would select all of the rows in the table Persons where the LastName column is equal to “Doe” or “Schmoe”.
This becomes handy when you need to narrow something down, but have a wide array of options and don’t wish to use multiple WHERE Commands. We could have as many Last Names in that list as we want and it would work fine.

2. An Example of what the IN Command from above will return can be seen below:

Original Table named Persons

ID First Name Last Name
1 Joe Schmoe
2 John Doe
3 Jane Doe
4 Jared Pittman

After Query is run:

ID First Name Last Name
1 Joe Schmoe
2 John Doe
3 Jane Doe

Conclusion

In this tutorial we learned how to use the IN Command in SQL. The IN Command is used to filter search results, and it is used in correlation with the WHERE Command. It can be very useful to use with large databases when you only need certain/small amounts of info from a table.

Download Source Files