Two Tables union query, sub-table FID has the same only fetch one, how to write SQL statements

Source: Internet
Author: User
Two Tables union query, sub-table FID has the same only fetch one, how to write SQL statements?
This post was last created by Dfwye on 2012-11-09 19:45:23 Edit two table union query, the child table FID has the same only one, how to write SQL statements?
Table Imgtitle
ID Title Time Conone

Child table Imginfo
img_id FID Miaoshu

Query CriteriaID = FID, sub-table FID has the same only fetch one bar
result isID title time Miaoshu table Imgtitle The value of the latest 10 records

I will only write SELECT ' id ', ' title ', ' Time ', ' Miaoshu ' from ' imgtitle ', ' Imginfo ' where Id=fid the ORDER by ID DESC LIMIT 10, this query knot The fruit is a sub-table Imginfo FID has the same also listed here.
How do I write a child table FID with the same SQL statement that takes only one?
Please advise the expert. Thank you!
------Optimal Solution--------------------
SELECT * from ' imgtitle ', ' imginfo ' where ' imgtitle '. ' ids ' = ' 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 two enthusiastic people, I used the 1 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.