Reputation: 10307
I'm making this query:
User.where("id = ? AND nome LIKE ?",id,nome)
and it returns nil when it should return a value.
If UI do the query for the id alone it works and for the name alone it works.
Can I do this another way? Or am I just way way off?
Upvotes: 1
Views: 316
Reputation: 1149
Here is another query:
User.find_by_sql(["select * from users where id = ? AND nome LIKE ?"],id,"%#{nome}%" ")
Upvotes: 0
Reputation: 9747
You need to add wildcard character %
around the nome
.
Try like this:
User.where("id = ? AND nome LIKE ?", id, "%#{nome}%")
Upvotes: 3