05 January, 2007

Views with ORDER BY

It is actually bad practice to include an ORDER BY in a View. The ORDER BY clause in the View definition will prevent you from selecting individual columns from the View.

When fetching from the View, your SQL query can be written to add the ORDER BY.
Always SELECT .... FROM ORDER BY .... thus, ORDER BY **after** selecting from the view.

My recommendation : never include an ORDER BY in a View defintion.

1 comment:

Anonymous said...

Good tip.

Thanks,

MG