# :select

**URL:** <https://www.ruby-forum.com/t/select/170935>\
**Category:** Rails\
**Created:** [June 24, 2009, 7:28am UTC](https://www.ruby-forum.com/t/select/170935 "2009-06-24T07:28:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [June 24, 2009, 7:28am UTC](https://www.ruby-forum.com/t/select/170935/1 "2009-06-24T07:28:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [June 24, 2009, 8:56am UTC](https://www.ruby-forum.com/t/select/170935/2 "2009-06-24T08:56:50Z")

</div>

On Jun 24, 6:28 am, Sijo Kg [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [June 24, 2009, 9:14am UTC](https://www.ruby-forum.com/t/select/170935/3 "2009-06-24T09:14:59Z")

</div>

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”

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [June 24, 2009, 10:08am UTC](https://www.ruby-forum.com/t/select/170935/4 "2009-06-24T10:08:58Z")

</div>

On Jun 24, 8:14 am, Sijo Kg [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [June 24, 2009, 10:27am UTC](https://www.ruby-forum.com/t/select/170935/5 "2009-06-24T10:27:43Z")

</div>

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\_name=  
first\_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?
