How do I join these or union these
I have these tables:
client
- idclient
- name
- reference
address
- idaddress
- idclient
inv
- idinvoice
- idaddress
- datetime
- total
payment
- idpayment
- idinvoice
- pdatetime
- amount
into - name, reference, time, id开发者_如何学编程payment, idinvoice, amount
i.e. datetime and pdatetime as time. inv.total as negative amount. Where idaddress = 9
OK, I'm making quite a few assumptions about what you're asking, but it looks like you are going for this:
select c.name , c.reference , c.pdatetime as time , p.idpayment , i.idinvoice , p.amount from payment p inner join inv i on p.idinvoice = i.idinvoice inner join address a on i.idaddress = a.idaddress inner join client c on a.idclient = c.idclient
add whatever filtering you need in a where clause
精彩评论