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
- “123”
- “123 45”
- “45 123”
- “12345”
- “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
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
- “123”
- “123 45”
- “45 123”
- “12345”
- “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