Closed chiurlo closed 13 years ago
Hello! How would I go about creating a query such as this:
SELECT * FROM `things` WHERE (`somefield` = $value OR `anotherfield` = $value) AND `status` = 'needs attention'
It's the parentheses that I can't figure out.
So far I've got ->where('somefield','=',$value) ->or_where('somefield','=',$value) ->and_where('status','=','needs attention')
but of course that is equivalent to
WHERE `somefield` = $value OR `anotherfield` = $value AND `status` = 'needs attention'
and thus retrieves too many results.
Thanks much, Alison
http://michaeldpeters.com/userguide/guide/api/Database_Query_Builder_Where#where_open
http://michaeldpeters.com/userguide/guide/api/Database_Query_Builder_Where#where_close
Thanks TdroL! I should have checked my email earlier -- I just found those pages of the userguide myself, minutes ago. But I really appreciate that you took the time to point me in the right direction.
Hello! How would I go about creating a query such as this:
It's the parentheses that I can't figure out.
So far I've got ->where('somefield','=',$value) ->or_where('somefield','=',$value) ->and_where('status','=','needs attention')
but of course that is equivalent to
and thus retrieves too many results.
Thanks much, Alison