-1

select * From Incomes where customer_id in (select id From Customers where name like "j%")

how do I make an inquiry on the rails? I want to make a customer survey!

  • 1
    I'm voting to close this question as off-topic because it is not in english. A spanish version of stackoverflow is on the way. But http://stackoverflow.com/ is for programming questions in english please. – max Aug 30 '15 at 06:07
  • @max it is not spanish – Juanjo Salvador Sep 19 '15 at 21:54
  • Sorry portugese. Which makes it even more off topic. http://pt.stackoverflow.com/ – max Sep 19 '15 at 22:10

1 Answers1

1

First of all: edit your question and re-write it all in english if you want help. StackOverflow it's in english.

Second, to make a SQL query in Rails, you can search in SO. I found this that can solve your question

Rails 3 execute custom sql query without a model

or

Rails SQL Query with find

Good luck.

Community
  • 1
  • 1
Juanjo Salvador
  • 1,073
  • 1
  • 12
  • 33
  • this worked for me Income.where(:customer_id => Customer.searchId(params[:search])).order('created_at DESC').page(params[:page]).per(12) and in the model where("name LIKE ?", "%#{search}%") thanks for help me – Joey Hammett Aug 30 '15 at 01:14
  • You're welcome. If you're question is solved, mark the answer with the solution as the solution to close the thread. – Juanjo Salvador Aug 30 '15 at 01:27