mysql - Order by a column in another table -
i have 2 mysql tables:
web_forums_threads | tid | title | |=================| | 1 | news post | web_forums_posts | pid | tid | content | date_created | date_modified | |===========================================================| | 1 | 1 | today,.. | unix timestamp | null or timestamp | | 2 | 1 | agree! | unix timestamp | null or timestamp |
i want select *
web_forums_threads
, , order recent date_created
value web_forums_posts
correct corresponding tid.
i feel though results i've found google may incorrect case, because multiple rows can exist threads' tid.
the example tried (with no success): select * web_forums_threads fid = :postfid order (select date_created web_forums_posts web_forum_posts.tid = web_forums_threads.tid) desc;
the syntax might wrong concept there. don't want add column threads table because i'd storing info twice (the first post acts threads content).
you have make join between 2 tables
select * web_forums_threads wft, web_forums_posts wfp wft.tid=wfp.tid order wfp.date_created
it that
Comments
Post a Comment