Two SQL LEFT JOINS produce incorrect result

后端 未结 3 1817
青春惊慌失措
青春惊慌失措 2020-11-22 08:56

I have 3 tables:

users(id, account_balance)
grocery(user_id, date, amount_paid)
fishmarket(user_id, date, amount_paid)

Both fishmarke

3条回答
  •  星月不相逢
    2020-11-22 09:25

    It's because when the user table joins to the grocery table, there are 3 records matched. Then each of those three records matches with the 4 records in fishmarket, producing 12 records. You need subqueries to get what you are looking for.

提交回复
热议问题