• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.