英文:
Java Criteria API - how to use MySQL's ANY_VALUE
问题
Is there any way to use Mysql ANY_VALUE in Criteria API?
I cant find any useful method in CriteriaBuilder, CriteriaQuery etc.
What i want achieve:
SELECT cartID, date, ANY_VALUE(customerName) FROM table WHERE type='A' GROUP BY cartID, date;
Why i need it? Because i dont want to add customerName to GROUP By clause ( its may be different for each row)
EDIT: I managed to do what i wanted by changing ANY_VALUE to MAX clause + if i want to ORDER BY customerName i need also to include MAX eg: 'ORDER BY MAX(customerName)
英文:
Is there any way to use Mysql ANY_VALUE in Criteria API?
I cant find any useful method in CriteriaBuilder, CriteriaQuery etc.
What i want achieve:
SELECT cartID, date, ANY_VALUE(customerName) FROM table WHERE type='A' GROUP BY cartID, date;
Why i need it? Because i dont want to add customerName to GROUP By clause ( its may be different for each row)
EDIT: I managed to do what i wanted by changing ANY_VALUE to MAX clause + if i want to ORDER BY customerName i need also to include MAX eg: 'ORDER BY MAX(customerName)
答案1
得分: 0
我成功地通过将ANY_VALUE更改为MAX子句来实现我想要的,如果我想按customerName排序,还需要包括MAX,例如:'ORDER BY MAX(customerName)。
英文:
I managed to do what i wanted by changing ANY_VALUE to MAX clause + if i want to ORDER BY customerName i need also to include MAX eg: 'ORDER BY MAX(customerName)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论