Help Required for joining 2 Tables in MySQL

Sudhir36's Avatar, Join Date: Sep 2013
Light Poster
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
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Do you want to be creating table or want to display content by joining tables?
0
Sudhir36's Avatar, Join Date: Sep 2013
Light Poster
Quote:
Originally Posted by shabbir View Post
Do you want to be creating table or want to display content by joining tables?
Want to Display Content by Joining tables
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Code:
Select * from comm as c INNER JOIN joincomm as jc ON (c.userid = jc.userid)
0
Sudhir36's Avatar, Join Date: Sep 2013
Light Poster
Quote:
Originally Posted by shabbir View Post
Code:
Select * from comm as c INNER JOIN joincomm as jc ON (c.userid = jc.userid)

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
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
The issue is not with the display of Data but then you are not storing the data correctly.
Sudhir36 like this
0
Sudhir36's Avatar, Join Date: Sep 2013
Light Poster
Quote:
Originally Posted by shabbir View Post
The issue is not with the display of Data but then you are not storing the data correctly.
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
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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 like this
0
Sudhir36's Avatar, Join Date: Sep 2013
Light Poster
Quote:
Originally Posted by shabbir View Post
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.
Ok Shabbir, Thanks allot for the Help
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by Sudhir36 View Post
Ok Shabbir, Thanks allot for the Help
The pleasure is all mine.
Sudhir36 like this