Hello,
I’m trying to use this function:
def getWhatsRelatedLinks(nid: Int): Seq[WhatsRelatedLink] = DB.readOnly { implicit session =>
sql"""
select tn.nid, count(tn.nid) as COUNT_TN_NID, u.alias, n.title
from taxonomy_index tn, url_alias u, node_field_data n
where tn.tid in (select tid from taxonomy_index where nid = $nid)
and tn.nid = u.nid
and tn.nid = n.nid
and n.status = 1
and n.nid != $nid
group by tn.nid
order by COUNT_TN_NID desc
limit 5
"""
.map(WhatsRelatedLink.fromDb)
.list()
.apply()
}
The SQL in that function works fine when I run it through the MySQL command line with a sample nid value, but I get this error when calling that function:
[error] (run-main-8) scalikejdbc.ResultSetExtractorException: Failed to retrieve value because Column 'count' not found.. If you're using SQLInterpolation, you may mistake u.id for u.resultName.id.
[error] scalikejdbc.ResultSetExtractorException: Failed to retrieve value because Column 'count' not found.. If you're using SQLInterpolation, you may mistake u.id for u.resultName.id.
[error] at scalikejdbc.WrappedResultSet.wrapIfError(WrappedResultSet.scala:35)
For some reason it can’t run the count function. I’m using ScalikeJDBC 3.1.0, mysql-connector-java 8.0.19, and a MySQL 5.6.35 database with Scala 2.12.8.
Any help is appreciated.
Thanks,
Al