views:

42

answers:

1

Based on my previous question I am running a query like so:

SELECT DISTINCT DATE_FORMAT(STR_TO_DATE(`value`, '%d/%m/%Y'), '%M %Y') AS `avail`
FROM table
ORDER BY STR_TO_DATE(`value`, '%d/%m/%Y')

Thevalue field is in the format dd/mm/yyyy and using STR_TO_DATE I convert it to yyyy-mm-dd. However I repeat that function call twice, so I was wondering (a) how efficient it is, and (b) if so, how to improve efficiency (and readability)?

I know in this case it's probably a micro-optimization but I'm interested anyway - there are surely more complex functions where an optimization would make a significant difference.

+1  A: 

the mysql query optimizer should take care of this.

mysql would allow using aliases in the group by clause, but every other DBMS does not

knittl