I need to find a way to get the ids starting with 11, in sql is with 'start with' and 'Connect by prior' but in HQL, how can I do that?, if there is a better way in grails, the help would be great, thanks!
(Updated: Sorry, I didn't write the other command which is: 'connect by prior')
Assuming the ID is a string, why not simply use a like clause:
where id like '11%'
Assuming it's not a string, you could cast it to a string:
where cast(id as STRING) like '11%'
or
where str(id) like '11%'
如果您的意思是查询ID大于或等于11的记录,那么例如,如果您有一个Books表,则HQL为
def books = Books.executeQuery("SELECT b from Books b WHERE id >= 11")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.