Hello,
Can anyone please tell me how do i write a sql query in rails in which
only one field in not null and the others are null.
FOr e.g. i want to find all records in which email is not null and all
the other fields are null. I do not want to mention the null fields
explicitly in query because there are many of them.
Thank you.
Ank Ag wrote:
Hello,
Can anyone please tell me how do i write a sql query in rails in which
only one field in not null and the others are null.
FOr e.g. i want to find all records in which email is not null and all
the other fields are null. I do not want to mention the null fields
explicitly in query because there are many of them.
Thank you.
not sure of the best way, here is one though:
imagine your object is called Business
@business = Business.find_by_sql([‘SELECT * FROM business WHERE email !=
null AND column2 = null AND column3 = null AND column4 = null’])