Sorry, don’t know how to formulate this question. I’ll try to explain. Here’s a query:
SELECT CONCAT(uno, due, tre) AS smth ... HAVING smth LIKE ...
It allows me to perform operations on aggregated multi-column data and, while it works ok, i don’t want the results of “smth” column to actually be selected and returned. Is it possible o do something like this?:
SELECT ... WHERE CONCAT(uno, due, tre) AS smth LIKE '...' OR smth LIKE '...' ...
Or does mysql already optimize a query with multiple identical concats to not concatinate the same data twice?
I hope the question is clear. Thank you for your thoughts.
Directly use the desired expression in the relevant
WHEREorHAVINGclause:MySQL only evaluates deterministic functions given the same arguments once per query, so despite the verbosity of the query it is no less efficient (save for a negligible amount of parsing).
Alternatively, you could perform an outer select on your query to only return the columns of interest: