Problem: Two tables, first one contains userid(constraint fk) and column ‘name’, second table contains two columns of int and id(foreign key), what I need, is to find max(column1-column2) and assign it with name from first table;
what I was doing:
mysql>
select u.name, MAX(table2.column1-table2.column2) As var
from table1 u, table2 b
where u.userID(from table1) = b.userID(from table2)
and (b.column1-b.column2) = var;
in this case it says “unknown column var”, is it possible withoud triggers/procedures?

any1?:)
Perhaps try a subquery instead?