Jump to content

Joining 2 Data Tables


JDevOnline

Recommended Posts

Hi,

 

I want to devise a query to join 2 mysql data tables. What i want to achieve is to join both the tables in such a way that the result would display all the rows of TableOne with the single row of TableTwo appended to every single row of the result.

 

TableOne has fields id, a, b, c and multiple rows.

Data sample:

1, a, b, c

2, d, e, f

 

TableTow has fields id, d, e, f and single row.

Data sample:

1, g, h, i, j, k

 

Desired Output:

a, b, c, g, h, i, j, k

d, e, f, g, h, i, j, k

 

 

Link to comment
Share on other sites

Hi,

 

I want to devise a query to join 2 mysql data tables. What i want to achieve is to join both the tables in such a way that the result would display all the rows of TableOne with the single row of TableTwo appended to every single row of the result.

 

TableOne has fields id, a, b, c and multiple rows.

Data sample:

1, a, b, c

2, d, e, f

 

TableTow has fields id, d, e, f and single row.

Data sample:

1, g, h, i, j, k

 

Desired Output:

a, b, c, g, h, i, j, k

d, e, f, g, h, i, j, k

Just use a join with no on statement.  

select fields from tableone join tabletwo
Link to comment
Share on other sites

I've tried the left join but hasn't worked well. I read about outer join but don't have the skill to code it.

Hmmm... if you feel you don't have the skill to code something and your only recourse is to tell us about it, perhaps you should cease your attempt at programming in php totally. After all the net has answers for everything and you apparently don't want to do the legwork to pick up a new skill. Trust me - being a coder/programmer/IT person is Nothing But Doing The Legwork!

  • Like 1
Link to comment
Share on other sites

Sounds like you want a cartesian join (cross join).

 

What have you tried so far?

 

 

 

Just use a join with no on statement.  

select fields from tableone join tabletwo

 

Barand and taquitosensei thank you very much for you kind assistance. You guys have pointed to the right direction, working on which helped me find the way, thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.