Jump to content

query help


xbl1
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...