Welcome Guest, Not a member yet? Register   Sign In
Help with Mysql Query - Subindex_string + group_concat
#1

(This post was last modified: 05-06-2021, 08:47 AM by tektion.)

Hi guys, 

New to CI and having some trouble with a few more advanced SQL queries . 

I am trying to use substring_index together with group_concat in order to make an array where I have 2 results of each unique group . 

I have tried the following :


Code:
$Array = $MyModel
   ->where('Column3 !=', 0)
   ->where('SUBSTRING_INDEX(GROUP_CONCAT(GROUP)),',1)
   ->orderBy('date', 'DESC')
   ->groupBy('GROUP')
   ->limit(2)
   ->find();

Could someone kindly help me fixing my query syntax ? 

Thanks in advance !
Reply


Messages In This Thread
Help with Mysql Query - Subindex_string + group_concat - by tektion - 05-05-2021, 05:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB