I would like to be able to use the 'AS' alias along with mysql without having to do query alignment, ie I want secondary queries to be named so that I can use them in the main query,
For example, in the case below the AS
is used nested
Example 1 with queries inside queries (and this way works )
SELECT ID FROM (
SELECT ID, msisdn FROM (
SELECT * FROM TT2
) AS T
) AS T
The way I'd like to do would be without nesting, like this:
Example 2 with external queries against the main query (this way does not work )
SELECT name,LEFT(occupation,1) AS letra FROM OCCUPATIONS ORDER BY name AS tab1;
SELECT letra FROM tab1 ORDER BY letra ASC;
The main difference between examples 1 and 2 is that in the first case, queries are nested inside one another. The second query has sub queries outside the main query.
Form 2 does not work, nor does it use parentheses, how do to use a pseudo-name for the query to be represented temporarily with an " alias " in a non-nested way, is it possible?