S
S
Stergy2019-08-26 19:05:36
PostgreSQL
Stergy, 2019-08-26 19:05:36

How to query a Ruby on Rails database via Active Record using regular expressions?

I need to get data from the Postgress database through an Active Record request, I use this request to work

Articles.where(group: "statuses", label: "Review Not Started")

It works fine, but finds values ​​that are strictly equal to "Review Not Started".
What I need is for him to find the values ​​in the label of which the phrase occurs not startedand he can have words in front or behind, and with a different case.
Those. label can be "Not started", "Review Not Started", "not started yet", "...bla bla Not Started bla bla..."
Is it possible to collect all these values ​​in a query using regular expressions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2019-08-26
@Stergy

regular expressions are not needed here - like is enough. typeArticles.where('label LIKE ?', '%Not Started%')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question