For joint queries between two tables, the fid of the sub-table has the same one and only takes one. how to write an SQL statement?

Source: Internet
Author: User
For joint queries between two tables, the fid of the sub-table has the same one and only takes one. how can I write an SQL statement? At the end of this post, dfwye edited two tables for joint queries from 2012-11-0919: 45: 23. The fid of the sub-table has the same one. how can I write an SQL statement? Table & nbsp; imgtitleid & nbsp; title & nbsp; & two tables join query, if the fid of a sub-table has the same one, how can I write an SQL statement?
At the end of this post, dfwye edited two table joint queries at 19:45:23 on. The child table fid has the same one and only takes one query. how do I write an SQL statement?
Table imgtitle
Id title time conone

Subtable imginfo
Img_id fid miaoshu

Query conditionsId = fid. The child table fid has the same one and only takes one
Result:Id title time miaoshu table imgtitle value of the latest 10 records

I will only write SELECT 'id', 'title', 'time', 'miaoshu 'FROM 'imgtitle', 'imginfo' where id = fid ORDER BY id DESC LIMIT 10, the results of this query are also listed in the imginfo fid of the subtable.
How can I write an SQL statement with the same fid as a sub-table?
Please kindly advise. Thank you!
------ Best solution --------------------
Select * from 'imgtitle', 'imginfo' where 'imtitle '. 'id' = 'miaoshu '. 'fid' group by 'miaoshu '. 'fid' order by 'imgtitle '. 'id' desc limit 10
------ Other solutions --------------------
SELECT  a. id  ,  a.title, a.time, b.miaoshu  FROM  `imgtitle` a
inner join
(
SELECT ` fid `,`miaoshu` from `imginfo` group by fid
) b
on a.id=b.fid ORDER BY a.id DESC LIMIT 10

------ Other solutions --------------------
Thanks to the two enthusiastic people, I used the first floor method. Thank you!

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.