开发者

How to join two tables mysql?

开发者 https://www.devze.com 2023-01-12 06:49 出处:网络
I have two tables:开发者_如何学C services id client service and clients id name email How to list table service and bring together the customer name that the customers table? field custo

I have two tables:

开发者_如何学C

services

  • id
  • client
  • service

and

clients

  • id
  • name
  • email

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,

I appreciate the help from you now


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


Try this,

SELECT * from services as s INNER JOIN clients as c on s.id=c.id 
0

精彩评论

暂无评论...
验证码 换一张
取 消