A语句
select t1.name,t2.samount,t2.place
from users t1,
(
select name,parentid,sum(amount) samount,place
from users,CasinoRolling where users.name=CasinoRolling.usergroup
group by parentid,place
) t2 where t1.id=t2.parentid//--------------------------------------
B语句
select t1.name,t2.amount,t2.place
from users t1 inner join
(
select parentid,sum(amount) as amount,place
from users inner join CasinoRolling ON (name=usergroup)
group by parentid,place
) t2 ON t1.id=t2.parentid
SELECT *
FROM employee
INNER JOIN department
ON employee.DepartmentID = department.DepartmentID等价于:
SELECT *
FROM employee, department
WHERE employee.DepartmentID = department.DepartmentID
或者MYSQL的官方文档。
http://dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html#join
13.2.7.1. JOIN语法