Welcome Guest, Not a member yet? Register   Sign In
How do I write this SQL statement ?
#6

[eluser]bEz[/eluser]
[quote author="whobutsb" date="1234929305"]For Nested Clauses like that I would just write it as a string in to the $this->db->where() method. I don't know how to write it any other way.[/quote]
Understood, a custom string would be the natural choice for such a short (overall two clause) string.

The method you provided would have required the second and third where portions to be combined with an "AND".
Code:
$this->db->where('abc.field2 = 2 AND (abc.field3 = 3 OR abc.field4 = 4)');

OR

Code:
$this->db->where('(abc.field2 = 2 AND (abc.field3 = 3 OR abc.field4 = 4))');
notice the extra set of parenthesis


Messages In This Thread
How do I write this SQL statement ? - by El Forum - 02-16-2009, 10:41 PM
How do I write this SQL statement ? - by El Forum - 02-17-2009, 12:32 AM
How do I write this SQL statement ? - by El Forum - 02-17-2009, 09:51 AM
How do I write this SQL statement ? - by El Forum - 02-17-2009, 03:51 PM
How do I write this SQL statement ? - by El Forum - 02-17-2009, 03:55 PM
How do I write this SQL statement ? - by El Forum - 02-17-2009, 03:57 PM
How do I write this SQL statement ? - by El Forum - 02-18-2009, 03:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB