[sql] Why do multiple-table joins produce duplicate rows?