Jump to content

query help


xbl1

Recommended Posts

Hello;I got 2 two tables which are Table 1(Thread) and Table 2(SubThread) from database. Please to click the link to see table 1 to table 4.I want to union two tables of the table 1 and table 2 together and get the final result as table 4. The table 3 is result of the union of the table 1 and table 2.After union the two tables, i want toSelect ThreadId, Username and PostIme from Table 3 where username="kam12"andif the threadId equal each other, pick up the row with the biggest value of the postTime,after above, order all the row by PostTime DESC My query as following, but it does work, and it give me the following massage when i run my query.could any one help me, please.Every derived table must have its own alias //error massage it give me

SELECT *FROM (select Id as threadId, userName, postTime from Threadunionselect threadId, userName, postTime from SubThread)WHERE postTimeIN (SELECT max( postTime )FROM (select Id as threadId, userName, postTime from Threadunionselect threadId, userName, postTime from SubThread)WHERE userName = "kam12"GROUP BY threadId)order by postTime;
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...