Welcome Guest, Not a member yet? Register   Sign In
Help with Complex MySQL Queries
#1

[eluser]Unknown[/eluser]
Hello! I have been using CI for along time and I love most of it. I just ran into a hiccup though. Is there a way to write more complex (grouped/math-like) SQL expressions using active records?

In other words, is it possible to translate the following using active records?

Code:
SELECT * FROM TableName WHERE id = 123 AND (approved = 1 OR created_by = current_user_id);

*Note the brackets

I ended up with queries that use LIKE as well and get much longer but the above is a simpler case. All I want to know is if it's possible to add brackets within expressions and how would you to that.

Thanks in advance!




Theme © iAndrew 2016 - Forum software by © MyBB