0

Try to run this syntax on localhost is fine, but on hosting seem like old version of phpmysql

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'groups as c WHERE a.user_id=b.id AND a.group_id=' at line 2

SELECT b.id,b.first_name,b.last_name,b.username,b.email,c.name,FROM_UNIXTIME(b.created_on) as created_on,b.active FROM users_groups as a , users as b , groups as c WHERE a.user_id=b.id AND a.group_id=c.id

Filename: models/Users_model.php

Line Number: 40

MODEL_FILE

function get_all_query()
    {
        $sql = "SELECT b.id,b.first_name,b.last_name,b.username,b.email,c.name,FROM_UNIXTIME(b.created_on) as created_on,b.active
                FROM users_groups as a , users as b , groups as c
                WHERE a.user_id=b.id
                AND a.group_id=c.id";
        return $this->db->query($sql)->result();
    }

Please..

Denis
  • 73
  • 13
  • `GROUPS` is a reserved word/keyword in newer versions of MySQL, try enclosing it with backticks in your query: `$sql = "SELECT b.id,b.first_name,b.last_name,b.username,b.email,c.name,FROM_UNIXTIME(b.created_on) as created_on,b.active FROM users_groups as a , users as b , \`groups\` as c WHERE a.user_id=b.id AND a.group_id=c.id";` – Marleen Jul 23 '22 at 09:55
  • https://stackoverflow.com/questions/52358165/tell-me-the-correct-syntax-in-mysql-8, https://stackoverflow.com/questions/23446377/syntax-error-due-to-using-a-reserved-word-as-a-table-or-column-name-in-mysql – Don't Panic Jul 23 '22 at 10:06

0 Answers0