Roy_Dorsthorst Roy_Dorsthorst - 1 month ago 6
C# Question

What's the difference between ORDER BY and ORDER BY ASC

I've been using mysql for a while now at my internship, and I'm wondering if there's a difference between declaring if your

ORDER BY
is
ASC
or not declaring it.

var result = (from r in db.table1 orderby r.datetime select r)


and

var result = (from r in db.table1 orderby r.datetime ascending select r)


note: both return the same result.

I could imagine that a difference in performance would matter in large applications, when using a large database.

Answer

By default, ORDER BY is sorted in ascending order, so I guess there are no differences between your requests.

From this documentation:

ASC Optional -- It sorts the result set in ascending order by expression (default, if no modifier is provider).

DESC Optional -- It sorts the result set in descending order by expression.

Comments