Topic: Regular Expressions in DB queries
As usual, I am trying to let Rails make my life easier. Today's hurdle is dealing with legacy databases.
Using the above technique as inspiration, I will be attempting to connect to my old database.
Thing is, I dont want to import all the data, only rows whose Section column equals A-Z or the number 1.
Even more poking at google reveals that my answer is to rock some regex in my MySQL query. Is this the right way to pull this off?
old_entries = OldEntry.find(:all, :conditions => 'Section REGEXP '[abcdefghijklmnopqrstuvwxyz1]'')
for o in old_entries do
n = Entry.new
n.title = o.title
n.body = o.body
I am still getting my head around both SQL syntax and REGEX so be gentle
Last edited by pimpmaster (2007-03-30 15:22:57)