Hi This is just an example .I have a model Person with fields first_name, last_name And after entering some records to the people table I tried the sql Person.find(:all,:select => "first_name,#{first_name+last_name} as full_name") But this is not working Could anybody please tell how can I make it work My ntention only just get result like first_name full_name abc abc d AG AG h Thanks -- Posted via http://www.ruby-forum.com/.
On Jun 24, 6:28 am, Sijo Kg <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi > This is just an example .I have a model Person with fields > first_name, last_name > And after entering some records to the people table I tried the sql > Person.find(:all,:select => "first_name,#{first_name+last_name} as > full_name")You don''t need the #{} in there. Fred> > But this is not working Could anybody please tell how can I make > it work My ntention only just get result like > first_name full_name > abc abc d > AG AG h > > Thanks > -- > Posted viahttp://www.ruby-forum.com/.
But when I do that I get error INT: No operator matches the given name and argument type(s). You might need to add explicit type casts. : SELECT first_name, first_name+last_name as full_name FROM "people" -- Posted via http://www.ruby-forum.com/.
On Jun 24, 8:14 am, Sijo Kg <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> But when I do that I get error > INT: No operator matches the given name and argument type(s). You might > need to add explicit type casts.check your database documentation for the appropriate way to concatenate two strings. Fred> : SELECT first_name, first_name+last_name as full_name FROM "people" > -- > Posted viahttp://www.ruby-forum.com/.
Hi Thanks for the reply I did it like arr = Person.find(:all,:select => "first_name,first_name||last_name as full_name") May I ask one more question related to this ? Here in arr for each element i get the methods like first_name first_namefirst_name? But I can''t see any such like full_name full_name= etc But I can access it like arr.first.full_name Why this? -- Posted via http://www.ruby-forum.com/.