Databases: Using the same table twice in a select returns duplicate rows