create table
SalesPerson(pid int primary key)
create table Sales(sid int primary key, spid int, cust int, amount int)
select * from SalesPerson, (select cust, amount from Sales where spid = pid order by amount desc fetch first 1 rows only)
According to the MySQL manual page, this is not permitted because "A derived table cannot normally refer to (depend on) columns of preceding tables in the same FROM
clause. " The page goes on to discuss a number of solutions which either are very complicated or require the LATERAL keyword.
Pyrrho v7 will automatically detect the need for a lateral derived table (or "lateral join") and will form the required join without using the LATERAL keyword. For example, the above naive solution is accepted and correctly computed by the current alpha build of Pyrrho at https://github.com/MalcolmCrowe/ShareableDataStructures . The feature is not discussed in the Pyrrho manual, because no special syntax is required.
I'd welcome comments on this feature, and a reference in the SQL standard for the rule that MySQL gives. Write to me at malcolm.crowe@uws.ac.uk .
No comments:
Post a Comment