[英]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 'docs'=> doc_id,doc_type_type_id,clients_cli_id
where doc_type_type_id 其中doc_type_type_id
Second Table: 第二张表:
'client' => cli_id '客户'=> cli_id
What I try to do is to join Client with doc that My query is: 我想做的是将带有我的查询的文档加入Client:
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. 这种格式的东西应该给您所有加入客户的发票。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.