Home  >  Article  >  Backend Development  >  MySQL related query problem?

MySQL related query problem?

PHP中文网
PHP中文网Original
2016-08-04 09:19:361150browse


Currently there are three tables:

They are: A B C

The relationship between A and B, A.uid = B.id

The relationship between B and C, B.uid = C.id

Now I want to pass When a MySQL statement directly queries table A, the information of table C can be found through table B, such as left join, etc. Please give me a demonstration sql statement, thank you

Reply content:

Currently there are three Table:

respectively include: A B C

The relationship between A and B, A.uid = B.id

The relationship between B and C, B.uid = C.id

Now I want to directly query A through a MySQL statement When creating a table, you can check out the information of table C through table B, such as left join, etc. Please give me a demonstration sql statement, thank you


The following is for reference only

SELECT * FROM A LEFT JOIN B ON A.uid=B.id LEFT JOIN C ON B.uid=C.id WHERE ...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn