Originally Posted by stevenryals
SELECT L.lowest, E.*
FROM expedia AS E,
( SELECT tag, MIN(price) AS lowest
GROUP BY tag ) AS L
WHERE E.tag = L.tag
ORDER BY E.tag, E.price
what is the significance of 'L' and 'E'
basically.. what exactly is happening here..
with L.lowest, L, and E not being declared before.. i'm a bit confused.. where would this go?
E and L are just "aliases". It allows me to use just "E." in place of "expedia." in the query and "L." to refer to the inner SELECT there.
It's basically the same thing as when I do MIN(price) AS lowest
, which then later allows me to refer to MIN(price)
with just the name lowest
You don't have to use alias for tables, but you do have to create one when you use an inner SELECT as I did there: I have to give the result of that inner SELECT some sort of name so that I can use it as a pseudo-table in other parts of the query.