Ask a basic mysql multi-table joint query related question: how to limit a table to query only one data
Source: Internet
Author: User
Ask a basic question about mysql multi-table joint query: how to limit a table to query only one data is as follows: query images from Table, at the same time, I joined Table B to check the image set name. now I only want to get a record from Table c. How can I write it? The current statement is probably like this & nbsp; select & nbsp;. *, B. name, c. * & nbsp; from & nbs ask for a basic mysql multi-table joint query question: how to restrict a table to query only one data
The requirement is as follows: query the image from Table a, view the image set name from Table B, and view the image comments from Table c.
Now I only want to get a record from Table c. How can I write it?
The current statement is probably like this select. *, B. name, c. * from a as a left join B as B on. pid = B. pid left join c as c on. pid = c. pid where. pid = XXX
But how can I modify the number of comments and the number of data records?
Analyze an SQL statement and use the php foreach loop to query B c after table A is checked. the efficiency difference is not big.
Only 20 points ~~~
Mysql join SQL
------ Solution --------------------
Cannot I use limit 1?
Or use the group by c. primary key.
------ Solution --------------------
Connected later: group by c. pid
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service