• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 4. Using SQL > Sorting Records

Sorting Records

It’s often not enough to limit the quantity of data you’re working with, especially when dealing with larger databases. Unless that data is in some useful order, even a hundred records can quickly become unwieldy. Fortunately, SQL provides a way to wrangle your data into an order that makes sense to you. SQL’s solution for ordering data is the ORDER BY clause. This clause lets you sort your recordset by one of the fields (such as name, price, or whether it’s on sale) and allows you to specify ascending or descending order.

To create a sorted recordset:

In the Application panel group, click on the Data Bindings panel.

Click the + (plus) button. Select Recordset (Query) from the menu.

In the Recordset dialog box, name the recordset, select your connection, and specify the appropriate table.

In the first Sort drop-down menu, select the field by which you wish to sort.

In the second Sort drop-down, select Ascending or Descending (Figure 4.17).

Figure 4.17. You can sort in either direction.

Click Test to see the sorted records (Figure 4.18).

Figure 4.18. Sorting, like all recordset operations, is previewable.

It should come as no surprise that you can click the Advanced button to see the SQL command (Figure 4.19).

Figure 4.19. Sorting adds an ORDER BY clause to your SQL.


  • By default, SQL sorts in ascending order. Although Dreamweaver always adds the keyword ASC, when you’re writing your own SQL, you can leave it out.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint