Sumit Srivastava
2012-Dec-07 04:20 UTC
Joining two tables giving ambigous column error on mysql
Hi, I am doing a join of two tables with a column with same name in both. I am using "includes" to have a full join. This is giving ambiguous column error. The columns cannot be removed from either of those and renaming any of the two would involve two many changes. So, is there any way this can be resolved? Regards, Sumit -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/jq7KYxfa_9cJ. For more options, visit https://groups.google.com/groups/opt_out.
Jordon Bedwell
2012-Dec-07 04:24 UTC
Re: Joining two tables giving ambigous column error on mysql
On Thu, Dec 6, 2012 at 10:20 PM, Sumit Srivastava <sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am doing a join of two tables with a column with same name in both. I am > using "includes" to have a full join. This is giving ambiguous column error. > The columns cannot be removed from either of those and renaming any of the > two would involve two many changes. So, is there any way this can be > resolved?Better context please. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Jim Ruther Nill
2012-Dec-07 04:35 UTC
Re: Joining two tables giving ambigous column error on mysql
On Fri, Dec 7, 2012 at 12:20 PM, Sumit Srivastava < sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I am doing a join of two tables with a column with same name in both. I am > using "includes" to have a full join. This is giving ambiguous column > error. The columns cannot be removed from either of those and renaming any > of the two would involve two many changes. So, is there any way this can be > resolved? >try this Foo.includes(:bar).order(''foos.name, bars.name'').where(''foos.name = ? AND bars.name = ?'', ''fooname'', ''barname'') just specify the table you are trying to access.> > Regards, > Sumit > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/jq7KYxfa_9cJ. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
sumit srivastava
2012-Dec-07 04:37 UTC
Re: Joining two tables giving ambigous column error on mysql
On 7 December 2012 09:54, Jordon Bedwell <envygeeks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Dec 6, 2012 at 10:20 PM, Sumit Srivastava > <sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I am doing a join of two tables with a column with same name in both. I > am > > using "includes" to have a full join. This is giving ambiguous column > error. > > The columns cannot be removed from either of those and renaming any of > the > > two would involve two many changes. So, is there any way this can be > > resolved? > > Better context please. >Table 1: id, name, email, ip_address Table 2: id, order_name, ip_address When I am joining these two tables. I receive ambiguous column error.> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
sumit srivastava
2012-Dec-07 05:59 UTC
Re: Joining two tables giving ambigous column error on mysql
Thanks. Got it fixed. Regards Sumit Srivastava The power of imagination makes us infinite... On 7 December 2012 10:07, sumit srivastava <sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> On 7 December 2012 09:54, Jordon Bedwell <envygeeks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On Thu, Dec 6, 2012 at 10:20 PM, Sumit Srivastava >> <sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > I am doing a join of two tables with a column with same name in both. I >> am >> > using "includes" to have a full join. This is giving ambiguous column >> error. >> > The columns cannot be removed from either of those and renaming any of >> the >> > two would involve two many changes. So, is there any way this can be >> > resolved? >> >> Better context please. >> > > Table 1: > id, name, email, ip_address > > Table 2: > id, order_name, ip_address > > When I am joining these two tables. I receive ambiguous column error. > >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
sumit srivastava
2012-Dec-07 07:17 UTC
Re: Joining two tables giving ambigous column error on mysql
On 7 December 2012 10:05, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Fri, Dec 7, 2012 at 12:20 PM, Sumit Srivastava < > sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hi, >> >> I am doing a join of two tables with a column with same name in both. I >> am using "includes" to have a full join. This is giving ambiguous column >> error. The columns cannot be removed from either of those and renaming any >> of the two would involve two many changes. So, is there any way this can be >> resolved? >> > > try this > > Foo.includes(:bar).order(''foos.name, bars.name'').where(''foos.name = ? AND > bars.name = ?'', ''fooname'', ''barname'') > > just specify the table you are trying to access. >How to write test cases for such errors? Is it possible?> > >> >> Regards, >> Sumit >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To view this discussion on the web visit >> https://groups.google.com/d/msg/rubyonrails-talk/-/jq7KYxfa_9cJ. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > ------------------------------------------------------------- > visit my blog at http://jimlabs.heroku.com > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Jim Ruther Nill
2012-Dec-07 07:27 UTC
Re: Joining two tables giving ambigous column error on mysql
On Fri, Dec 7, 2012 at 3:17 PM, sumit srivastava < sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 7 December 2012 10:05, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> >> On Fri, Dec 7, 2012 at 12:20 PM, Sumit Srivastava < >> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> Hi, >>> >>> I am doing a join of two tables with a column with same name in both. I >>> am using "includes" to have a full join. This is giving ambiguous column >>> error. The columns cannot be removed from either of those and renaming any >>> of the two would involve two many changes. So, is there any way this can be >>> resolved? >>> >> >> try this >> >> Foo.includes(:bar).order(''foos.name, bars.name'').where(''foos.name = ? >> AND bars.name = ?'', ''fooname'', ''barname'') >> >> just specify the table you are trying to access. >> > > How to write test cases for such errors? Is it possible? >If you''re going to ask me, I personally think that this specific error should not be written a test case. In the first place, the code will not run if there is such an error so that code shouldn''t be committed.> > > >> >> >>> >>> Regards, >>> Sumit >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/rubyonrails-talk/-/jq7KYxfa_9cJ. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> -- >> ------------------------------------------------------------- >> visit my blog at http://jimlabs.heroku.com >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
tamouse mailing lists
2012-Dec-07 13:53 UTC
Re: Joining two tables giving ambigous column error on mysql
On Fri, Dec 7, 2012 at 1:27 AM, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Dec 7, 2012 at 3:17 PM, sumit srivastava > <sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> On 7 December 2012 10:05, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> On Fri, Dec 7, 2012 at 12:20 PM, Sumit Srivastava >>> <sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>> Hi, >>>> >>>> I am doing a join of two tables with a column with same name in both. I >>>> am using "includes" to have a full join. This is giving ambiguous column >>>> error. The columns cannot be removed from either of those and renaming any >>>> of the two would involve two many changes. So, is there any way this can be >>>> resolved? >>> >>> >>> try this >>> >>> Foo.includes(:bar).order(''foos.name, bars.name'').where(''foos.name = ? AND >>> bars.name = ?'', ''fooname'', ''barname'') >>> >>> just specify the table you are trying to access. >> >> >> How to write test cases for such errors? Is it possible? > > > If you''re going to ask me, I personally think that this specific error > should not be written a test case. > In the first place, the code will not run if there is such an error so that > code shouldn''t be committed.Well, no, that''s not really the test you want to write. The test to write is (before you''ve implemented the (bad?) code) one that will compare a given initial condition (setting test data in tables) will return the expected value (a data set with the combined tables). Often writing the test will enable you to determine how to write the code, and foresee potential problems. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.