In a previous post, we discussed how to write a select statement. Over the next several posts we will discuss how to use the WHERE keyword to filter records by numbers, character data, dates and times, and NULL values. This post specifically will focus on filtering records by integer numbers.
In the code above, we are using the WHERE keyword to return the product that has a ProductID that = 2. We could also use the greater than (>), less than (<), as well as other equality operators. In this case, our SELECT statement returns the one record where ProductID equals 2.
If we wanted to return more than one value we could write our WHERE statement one of two ways. Either by using the OR statement or by using the IN predicate. (Editors Note: In this example, we are displaying both options, but you can only use one WHERE keyword per SELECT statement.)
Both of these statements will run the same way and return the same data. If you are filtering by more than two values, the IN predicate might be more efficient from a typing standpoint.