JDevOnline Posted February 21, 2017 Share Posted February 21, 2017 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 Quote Link to comment Share on other sites More sharing options...
Barand Posted February 21, 2017 Share Posted February 21, 2017 Sounds like you want a cartesian join (cross join). What have you tried so far? Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted February 21, 2017 Share Posted February 21, 2017 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 Quote Link to comment Share on other sites More sharing options...
Barand Posted February 21, 2017 Share Posted February 21, 2017 That's what I said. 1 Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted February 21, 2017 Share Posted February 21, 2017 That's what I said. Sorry didn't see that. Just skimmed through and didn't see an example. Quote Link to comment Share on other sites More sharing options...
JDevOnline Posted February 21, 2017 Author Share Posted February 21, 2017 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. Quote Link to comment Share on other sites More sharing options...
Barand Posted February 21, 2017 Share Posted February 21, 2017 1 ) No one has mentioned a LEFT join. 2 ) If you read the replies you would see that taquitosensei spoonfed you the solution (reply #3) Quote Link to comment Share on other sites More sharing options...
ginerjm Posted February 21, 2017 Share Posted February 21, 2017 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! 1 Quote Link to comment Share on other sites More sharing options...
JDevOnline Posted February 21, 2017 Author Share Posted February 21, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.