I found the answer....
my_request = myTable.find(:all, :conditions => ["my_column REGEXP
:test> ", {:test => "[[:<:]]123[[:>:]]"} ])
cheers guido
Guido Holz wrote:> Hi there...
>
> easy question and I hope I will get an easy anwser...
>
> I have in my database a table named "my_table" and a column
''my_column''
>
> in my_column I have five entries as string
>
> 1. "123"
> 2. "123 45"
> 3. "45 123"
> 4. "12345"
> 5. "45123"
>
> Now I need a sql-statement to select ONLY the datasets with "123"
(this
> are the sets 1. 2. 3.)... before the "123" it can be that there
is {0,}
> whitespaces.. at the and of "123" the same....
>
> but if i try
>
> my_request = myTable.find(:all, :conditions => ["my_column REGEXP
:test
> ", {:test => "[ ]*123[ ]*"} ])
>
> as the result I get all datasets... :-(
>
> I used [ ] instead of \s because I don´t know realy how to use the
> spezial characters in this statement
>
> I there anyone who knows how to use regexp in find-statements?!?
>
> thanks for helping
--
Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---