MySQL mysql如何加入两个表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3536283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:55:50 来源:igfitidea点击:
How to join two tables mysql?
提问by GWW
I have two tables:
我有两个表:
services
服务
- id
- client
- service
- ID
- 客户
- 服务
and
和
clients
客户
- id
- name
- ID
- 姓名
- 电子邮件
How to list table service and bring together the customer name that the customers table? field customer services in the table has the id of the customer at the customer table,
如何列出表服务并汇集客户表的客户名称?表中的字段客户服务具有客户表中客户的id,
I appreciate the help from you now
我感谢你现在的帮助
回答by GWW
SELECT * FROM table1 LEFT JOIN table2 on table1.id = table2.id
回答by Daniel Vandersluis
SELECT ...
FROM services AS s
JOIN clients AS c
ON s.client = c.id
WHERE ...
回答by Ignacio Vazquez-Abrams
SELECT ...
FROM services AS s
INNER JOIN clients AS c
ON s.client=c.id
回答by Sat Siva
Try this,
尝试这个,
SELECT * from services as s INNER JOIN clients as c on s.id=c.id