Update Subquery Help
am 27.07.2007 22:14:47 von rh1200laHi there. I'm in need of assistance with an update query. I am doing
a data migration for a message board. All went fine except some of
the mappings didn't cross over. Here is what I need to do:
Tables:
Thread: threadid, firstpostid, lastpostid
Post: postid, threadid, dateline
I need to map the first post from post.postid to thread.firstpostid
and the last post from post.postid to thread.lastpost id.
I can get these values by two queries if I know the threadid
First Post = select postid, threadid from post where post.threadid =
1 order by FROM_UNIXTIME(dateline) asc limit 1
Last Post = select postid, threadid from post where post.threadid = 1
order by FROM_UNIXTIME(dateline) desc limit 1
Does anyone know how I can seamlesly update the Thread table with
these post id's respectively through one subquery?
I am using MySQL 5.x
Thanks in advance