I know there are three main types of syntax's for the where clause:
- Pure String
- Array
- Hash
Specifying AND for the where clause is straight forward:
#Pure String syntax
@people= Person.where("name = 'Neil' AND age = 27")
#Array syntax
@people = Person.where(["name = ? AND age = ?", 'Neil', 27])
#Hash syntax
@people = Person.where({name: "Neil", age: 27})
Specifying OR for this same where clause is stumping me for the hash syntax. Is it possible?
#Pure String syntax
@people= Person.where("name = 'Neil' OR age = 27")
#Array syntax
@people = Person.where(["name = ? OR age = ?", 'Neil', 27])
#Hash syntax DOESN'T WORK
@people = Person.where({name: "Neil" OR age: 27})
Aucun commentaire:
Enregistrer un commentaire