如何join两个表mysql?
我有两个表格:
服务
- ID
- 客户
- 服务
和
客户
- ID
- 名称
- 电子邮件
如何列出餐桌服务并汇集客户所在的客户名称? 表中的现场客户服务在客户表中具有客户的ID,
我感谢你的帮助
SELECT * FROM table1 LEFT JOIN table2 on table1.id = table2.id
SELECT ... FROM services AS s JOIN clients AS c ON s.client = c.id WHERE ...
SELECT ... FROM services AS s INNER JOIN clients AS c ON s.client=c.id
尝试这个,
SELECT * from services as s INNER JOIN clients as c on s.id=c.id