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!