Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MySQL (http://www.go4expert.com/forums/mysql-forum/)
-   -   Help Required for joining 2 Tables in MySQL (http://www.go4expert.com/forums/help-required-joining-2-tables-mysql-t29830/)

Sudhir36 24Sep2013 15:13

Help Required for joining 2 Tables in MySQL
 
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

shabbir 24Sep2013 17:59

Re: Help Required for joining 2 Tables in MySQL
 
Do you want to be creating table or want to display content by joining tables?

Sudhir36 24Sep2013 18:21

Re: Help Required for joining 2 Tables in MySQL
 
Quote:

Originally Posted by shabbir (Post 100094)
Do you want to be creating table or want to display content by joining tables?

Want to Display Content by Joining tables

shabbir 24Sep2013 18:47

Re: Help Required for joining 2 Tables in MySQL
 
Code:

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

Sudhir36 25Sep2013 10:19

Re: Help Required for joining 2 Tables in MySQL
 
Quote:

Originally Posted by shabbir (Post 100097)
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

shabbir 25Sep2013 11:05

Re: Help Required for joining 2 Tables in MySQL
 
The issue is not with the display of Data but then you are not storing the data correctly.

Sudhir36 25Sep2013 11:10

Re: Help Required for joining 2 Tables in MySQL
 
Quote:

Originally Posted by shabbir (Post 100102)
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

shabbir 25Sep2013 11:38

Re: Help Required for joining 2 Tables in MySQL
 
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 25Sep2013 12:24

Re: Help Required for joining 2 Tables in MySQL
 
Quote:

Originally Posted by shabbir (Post 100105)
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

shabbir 25Sep2013 12:52

Re: Help Required for joining 2 Tables in MySQL
 
Quote:

Originally Posted by Sudhir36 (Post 100106)
Ok Shabbir, Thanks allot for the Help

The pleasure is all mine.


All times are GMT +5.5. The time now is 14:06.