У меня есть приведенный ниже запрос, который получает правильные результаты в mysql, когда я пишу тот же запрос в Grails, он выдает ошибку «Путь, ожидаемый для соединения»
select u.username,u.transactioncode,count(distinct t.rolename) roles
from user u
left join transaction t on u.transactioncode=t.transactioncode
group by u.username, u.transactioncode;
How to change the query?
Modifying the query to make it work in grails
function(int id)
{
def sql = new Sql(dataSource)
def output = sql.rows("select
u.username,u.transactioncode,count(distinct t.rolename) roles from
user u left join transaction t on
u.transactioncode=t.transactioncode where u.userid=:id group by
u.username, u.transactioncode")
sql.close();
}
It throws an error in the where condition 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 ':id.