Filtering Data with WHERE Clauses
The first half of today's lesson will show you how to use a WHERE clause to restrict the rows returned from a table. Learning to limit rows with WHERE will improve system performance by reducing the amount of data returned to (and processed by) your application programs.
Queries that don't include a WHERE clause operate on all rows in a table. Later, when you learn to UPDATE and DELETE data, you will use WHERE clauses to determine what data in your tables is deleted and/or updated. If you don't include a WHERE clause in a DELETE statement, you will delete every row in the table, which is not a good idea. An example of an update that affects all the rows in a table is
Update Orders Set OrderDate = '1/1/2000' ...
Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.