Querying Database to retrieve all the records containing a given string in an array of strings present in the record

I'm having an Active Record in my rails application in which each row of the table MyTable contains:

  1. stringArr --> an array of string
  2. id

Now I want to query my database to pull all the records in which a particular queryString is present in strinArr of that record.

I know we can do MyTable.where(xyz:someXYZ) to pull all the records with xyz value as someXYZ?

But how can I do this query?


To fetch all record, which contains queryString in an array of records, you can do -

MyTable.where("column_name LIKE ?","'%queryString%'"})

This will do exact query string search means return all data, which column_name contains queryString.

You can use the sql like clause

MyTable.where("stringArr LIKE :keywords",{keywords: '%querystring%'})

Need Your Help

jQuery aspx error function always called, even with apparently valid return data

jquery ajax cherrypy

I am making an ajax call using jQuery (jquery-1.5.2.min.js). The server receives the call. fiddler shows the response text coming back apparently correct. But back in javascript my error: function is

Running a Python web server as a service in Windows

python windows webserver

I have a small web server application I've written in Python that goes and gets some data from a database system and returns it to the user as XML. That part works fine - I can run the Python web s...