[thelist] mysql - null - returns results anyway

John Townsend jft at worrigee.net
Wed Dec 23 04:54:10 CST 2009


>  From: r937 <rudy at r937.com>
>  Subject: Re: [thelist] mysql - null - returns results anyway
>  Sent: 23 Dec '09 14:53
>  <...munch...>  
>  ORDER BY is ~never~ appropriate for a view
>  full stop
>  ;o)

No, that's not the case.
MySQL allows for an ORDER BY in the definition of a view.
It is also smart enough to ignore that ORDER BY statement if the select statement you write
against the view has its own ORDER BY statement.
See http://dev.mysql.com/doc/refman/5.0/en/create-view.html    
Quite some way down the page is the quote:
"ORDER BY is allowed in a view definition, but it is ignored if you select from a view using a statement that has its own ORDER BY."
Regards,
John Townsend


More information about the thelist mailing list