简体   繁体   中英

Use inner join, left join or right join for join 2 tables

I'm realizing a project which raises me the next tables:

For being more specific: First table:

'docs' => doc_id, doc_type_type_id, clients_cli_id
where doc_type_type_id

  1. invoices
  2. reference guides

Second Table:

'client' => cli_id

What I try to do is to join Client with doc that My query is:

Show Client with his invoice and reference guide:

SELECT c.cli_name, d1.doc_file as f1 , d2.doc_file as f2 FROM clients c INNER JOIN docs d1 ON d1.client_cli_id = c.cli_id INNER JOIN docs d2 ON d2.client_cli_id = c.cli_id WHERE d1.doc_fec=d2.doc_fec
    select * from docs
    inner join client on docs.clients_cli_id = client.cli_id
    where doc_type_type_id = 1

Something in this format should give you all invoices joined to client.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM