CodeIgniter Forums

Full Version: Help writing Sql with CI4 active record
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello. I 'm struggling to write sql with subquery, How can I write it with codeigniter methods.

PHP Code:
SELECT, ( as category
                FROM product_feature p
                JOIN categories c ON p
                WHERE p
.id IN(
                    SELECT MAX(p.idFROM product_feature p 
                    GROUP BY p

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

Also, don't forget you write out the whole query using query bindings (