Home > Backend Development > PHP Tutorial > MySQL related query problem?

MySQL related query problem?

PHP中文网
Release: 2016-08-04 09:19:36
Original
1167 people have browsed it


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 ...
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template