Imagine that you had a database table named Albums that contained the following columns: AlbumID, Name, Artist, and DatePurchased. Write a SQL query to retrieve the name of the albums, ordered alphabetically.
Start by dragging a SqlDataSource control onto the Design view of an ASP.NET page and click the Configure Data Source link. Next, specify the database's connection information. From the Configure Select Statement screen, choose the Albums table from the drop-down list and select the Name and DatePurchased columns. Next, click the WHERE button to bring up the Add WHERE Clause dialog box.
In that dialog box, add two filter expressions. For the first, on AlbumID use the > operator with a Source of None and a Value of 5. The second filter expression would be on the Artist column, using the = operator, with a Source of None and a Value of Pavement.
This exercise is intended to improve your proficiency with SQL. Open the query window by right-clicking on the database in the Database Explorer and choosing New Query.
In the query window craft the SQL query to retrieve those books whose BookID is less than or equal to 3. (You can enter the SQL directly into the SQL pane or use the diagram or criteria panes if you prefer.) Note the list of books you see when testing the query. Now, run another query, this time retrieving those books that have a price greater than $10.00. (You are encouraged to experiment with the query window further.)