Update Subquery Help

This is a discussion on Update Subquery Help within the MySQL Database forums, part of the Database Forums category; Hi there. I'm in need of assistance with an update query. I am doing a data migration for a ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-27-2007
rh1200la@gmail.com
 
Posts: n/a
Default Update Subquery Help

Hi 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

Reply With Quote
  #2 (permalink)  
Old 07-29-2007
Paul Lautman
 
Posts: n/a
Default Re: Update Subquery Help



Do not multi-post. Cross-post if you must but don't multi post
It waste's people's time.
http://www.blakjak.demon.co.uk/mul_crss.htm


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:01 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0