使用 SQL Server 2008 R2 哪个更好(更快、更少的中间表、更少的内存使用)和通常的做法?
SELECT staff.id, staff.name, details.address, salary.hourly_rate,
manager.name, boss.name
FROM STAFF_TABLE staff
LEFT JOIN STAFF_DETAILS_TABLE details on staff.id = details.id
LEFT JOIN STAFF_SALARY_TABLE salary on staff.id = salary.id
LEFT JOIN STAFF_TABLE manager on staff.manager_id = manager.id
LEFT JOIN STAFF_TABLE boss on staff.boss_id = boss.id
或者
SELECT staff.id, staff.name,
(SELECT address FROM STAFF_DETAILS_TABLE id = staff.id) [address],
(SELECT hourly_rate FROM STAFF_SALARY_TABLE WHERE id = staff.id) [hourly_rate],
(SELECT name FROM STAFF_TABLE WHERE id = staff.manager_id) [manager_name],
(SELECT name FROM STAFF_TABLE WHERE id = staff.boss_id) [boss_name]
FROM STAFF_TABLE staff
谢谢!