进行从左到右加入的正确方法是什么?

时间:2019-01-28 19:46:29

标签: mysql sql

我正在尝试从数据库中获取数据,但是在以这种方式获取数据时遇到了问题

|42|127-1|COMPANY LTDA|ORLANDO |MIT|91919191|Address 1
|42|127-1|COMPANY LTDA|ORLANDO |MIT|92929292|Address 2

我做两个LEFT JOIN来从客户那里获取地址和电话。

这是我的查询:

SELECT cl.*,phone.c_phone_client,address.c_address_client
FROM  c_client AS cl 
  LEFT JOIN c_client_phone_fk AS phone ON phone.c_id_client = cl.c_id_client
  LEFT JOIN c_client_address_fk AS address ON phone.c_id_client = cl.c_id_client
 WHERE cl.c_id_client='127-1' 
 GROUP BY phone.c_phone_client,address.c_address_client
 ORDER BY address.c_address_client

通过此查询,我得到以下结果:

|42|127-1|COMPANY LTDA|ORLANDO|MIT|91919191|Address 1
|42|127-1|COMPANY LTDA|ORLANDO|MIT|92929292|Address 1
|42|127-1|COMPANY LTDA|ORLANDO|MIT|91919191|Address 2
|42|127-1|COMPANY LTDA|ORLANDO|MIT|92929292|Address 2

如何解决我的查询?

0 个答案:

没有答案