which is the correct join in this case ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • realin
    Contributor
    • Feb 2007
    • 254

    which is the correct join in this case ?

    hi guys,

    i have two tables as
    Code:
    [B]thread_post[/B]
    
    post_id
    thread_id
    thread_cat
    thread_post_id
    thread_post_time
    thread_ip
    thread_username
    
    [B]and thread_text[/B]
    
    post_id
    post_subject
    post_text
    i want to know which should be the join used here to fetch the post_text from the later table by comparing he post_id fields and with a where condition as thread_id
    currently i am using is

    [code=mysql]select t1.post_text,t1 .post_id,t2.thr ead_post_id,t2. thread_username from thread_text as t1 join thread_post as t2 on t2.post_id=t1.p ost_id where t2.thread_id=$i d[/code]

    is this perfect ?

    Can this be done without join ?
    And what if my post_id become unequal.. just in case a query is executes for one table and not for other..
    let me know thanks :)
    Last edited by mwasif; Sep 25 '07, 07:45 PM. Reason: Replaced [CODE] with [CODE=mysql]
Working...