You are here: Update Subquery Help « PHP SQL « IT news, forums, messages
Update Subquery Help

Posted by rh1200la on 07/27/07 20:14

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация