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
Post a Comment