ruby on rails - SQL query for records that are substrings of input -


consider users table has column called name has following 3 rows.

  • alice
  • bob
  • carl

i construct query returns records in name substring of input. example, if query alice jackson, want alice. if search bobby, want bob. if search car, want no matches. sort of reversed like.

can done? , can done using activerecord syntax?

you (sql server syntax):

select name users 'your query' + ' ' name + ' %'; 

the following find alice:

select name users 'alice jackson' + ' ' name + ' %';  select name users 'alice' + ' ' name + ' %'; 

the following not find alice:

 select name  users  'ali' + ' ' name + ' %'; 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -