Welcome Guest, Not a member yet? Register   Sign In
Help writing Sql with CI4 active record
#1

Hello. I 'm struggling to write sql with subquery, How can I write it with codeigniter methods.
Thanks!

//SQL
PHP Code:
SELECT p.idp.catIdp.imagec.id, (c.name) as category
                FROM product_feature p
                JOIN categories c ON p
.catId c.id
                WHERE p
.id IN(
                    SELECT MAX(p.idFROM product_feature p 
                    GROUP BY p
.catId 
                 

Reply
#2

https://codeigniter.com/user_guide/datab...cific-data

Quote:$builder->where() - 5) Subqueries: You can use an anonymous function to create a subquery.
Reply
#3

@venance,

Also, don't forget you write out the whole query using query bindings (https://codeigniter.com/user_guide/datab...y-bindings).
Reply




Theme © iAndrew 2016 - Forum software by © MyBB