1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Help Required for joining 2 Tables in MySQL

Discussion in 'MySQL' started by Sudhir36, Sep 24, 2013.

  1. Sudhir36

    Sudhir36 New Member

    Hello Friends,

    I need help in Joining 2 Tables.

    1st table with Created community details

    SQL>> SELECT * FROM comm;

    Cid cname userid
    1 xxx 311
    2 yyy 311
    3 zzz 311
    4 xyy 64
    5 zzy 64
    6 xxz 64


    2nd table with Joined community details

    SQL>> SELECT * FROM joincomm;

    id cid userid
    1 xyy 311
    2 zzy 311
    3 xxz 311

    Now i want both i joined and created records

    Example

    cname userid

    xxx 311
    yyy 311
    zzz 311
    xyy 311
    zzy 311
    xxz 311

    Can u please help me out to solve this query
     
  2. shabbir

    shabbir Administrator Staff Member

    Do you want to be creating table or want to display content by joining tables?
     
  3. Sudhir36

    Sudhir36 New Member

    Want to Display Content by Joining tables
     
  4. shabbir

    shabbir Administrator Staff Member

    Code:
    Select * from comm as c INNER JOIN joincomm as jc ON (c.userid = jc.userid)
     
  5. Sudhir36

    Sudhir36 New Member


    Hello Shabbir,

    Thanks for the reply but its unfortunate, It Doesn't Satisfy my condition.....

    Here is the Requirement,

    My UserId = 311

    I created 3 communities like ( CommunityID = 111,112,113)

    I Joined 3 Communities Which were created by Others like (Community ID = 222,223,224 Note: let us think these 3 communities were created by user 312)

    Now i result must be Showing all 6 communities (111,112,113,222,223,224)

    This is The Requirement...
    Can u please help me out to solve this issue
     
  6. shabbir

    shabbir Administrator Staff Member

    The issue is not with the display of Data but then you are not storing the data correctly.
     
    Sudhir36 likes this.
  7. Sudhir36

    Sudhir36 New Member

    Storing of Data every thing is fine Shabbir, as i cant share the Data here. I given a Sample example.

    Is it Possible to retrieve data in that way
     
  8. shabbir

    shabbir Administrator Staff Member

    If you have userid based on which the data is stored in both tables and joining them does not give the data then I am not sure.
     
    Sudhir36 likes this.
  9. Sudhir36

    Sudhir36 New Member

    Ok Shabbir, Thanks allot for the Help
     
  10. shabbir

    shabbir Administrator Staff Member

    The pleasure is all mine.
     
    Sudhir36 likes this.

Share This Page