【问题标题】:How do I join these or union these我如何加入这些或联合这些
【发布时间】:2010-07-22 20:59:50
【问题描述】:

我有这些表:

客户

  • idclient
  • 姓名
  • 参考

地址

  • 身份证地址
  • idclient

inv

  • 发票
  • 身份证地址
  • 日期时间
  • 总计

付款

  • idpayment
  • 发票
  • 日期时间
  • 金额

into - 姓名、参考、时间、idpayment、idinvoice、金额

即datetime 和 pdatetime 作为时间。 inv.total 作为负数。其中 idaddress = 9

【问题讨论】:

  • 请把你的问题和文字说清楚。

标签: mysql


【解决方案1】:

好的,我对你的要求做了很多假设,但看起来你正在这样做:

选择 c.name , c.参考 , c.pdatetime 作为时间 , p.idpayment , i.idinvoice , p. 数量 从 付款 内联inv i 在 p.idinvoice = i.idinvoice 内连接地址 a 在 i.idaddress = a.idaddress 内连接客户端c 在 a.idclient = c.idclient

在 where 子句中添加您需要的任何过滤

【讨论】:

  • inv.total inv.total 作为负数怎么样 如果有 3 张发票和 3 笔付款,我希望有 6 行。 3 行 idpayment 列将为 NULL,3 行 idinvoice 也将为 NULL。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多