CASTING attributes for Ordering on a Doctrine2 DQL Query

后端 未结 7 466
一向
一向 2020-12-03 03:33

I am trying to get Doctrine2 Entities, ordered by their ID which apparently is a String even though it contains only Numbers. So what I would like to do is

7条回答
  •  自闭症患者
    2020-12-03 03:56

    I think you want order by entity1. if your entity1 data type is integer then no need to change it into integer or if it is not then you should do it. below is query for you.try this one.

    select entity1,cast(entity1 as integer) as order_id from Table_Name order by 1 asc;
    

提交回复
热议问题