0
$query = $this->db->group_by('hs_tktno');
$query = $this->db->where('hs_toid', $id);
$query = $this->db->order_by('hs_id', "desc");
$query = $this->db->get('table');
$data["list"] =  $query->result();

Im Getting the following error when i try to excute the above code any ideas?

Error Number: 1055

'dbname.table.hs_id' isn't in GROUP BY

SELECT * FROM (table) WHERE hs_status = '0' GROUP BY hs_tktno

Community
  • 1
  • 1
Mumin Gazi
  • 103
  • 2
  • 10
  • use $query = $this->db->group_by('hs_tktno'); after $query = $this->db->where('hs_toid', $id); – Saty Apr 02 '15 at 13:36
  • write where clause first then you write group by $query = $this->db->where('hs_toid', $id); $query = $this->db->group_by('hs_tktno'); – Saty Apr 02 '15 at 13:38

2 Answers2

0

Didn't understood much by question, but your query written is wrong. It should be like this,

$this->db->group_by('hs_tktno');
$this->db->where('hs_toid', $id);
$this->db->order_by('hs_id', "desc");
$query = $this->db->get('table');

return $query->result();
Parag Tyagi
  • 8,780
  • 3
  • 42
  • 47
0

I also had this issue, the solution that I found was to change your my.cnf or my-default.cnf in your server. For my case, I am using mac, this file can be found at /usr/local/mysql/support-files/

Steps to produce solution:

  1. Open Terminal
  2. cd /usr/local/mysql/support-files/
  3. sudo vim my.cnf
  4. scroll all the way to the bottom and press i to insert
  5. replace the existing slq_mode with sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
  6. press esc to exit input mode
  7. type :wq to save and close vim
  8. now restart your mysql with sudo /usr/local/mysql/support-files/mysql.server restart or sudo service mysql restart
  9. All done and you are set to enjoy your coding. Have fun :)

For some who couldn't find their my.cnf file. Please refer to this for Mark B answer. This will help you to find your my.cnf .

If you only have my-default.cnf, you could just copy it to ~/.my.cnf with the command sudo cp /usr/local/mysql/support-files/my-default.cnf ~/.my.cnf and remember to restart after that.

Community
  • 1
  • 1
iCezz
  • 624
  • 1
  • 7
  • 14