Welcome Guest, Not a member yet? Register   Sign In
Query Builder order by lenght
#1

(This post was last modified: 01-17-2023, 05:48 PM by pippuccio76.)

Hi ,i have a field on db alphanumeric (A01,A20,A110) , to sorting properly  i must sort by LENGHT(nome)   , nome  but if i do this :
Code:
$scaffali_model->orderBy('LENGHT(nome)  ASC , nome ASC')->findAll();
I have this error : FUNCTION my_magazzinoes.LENGHT does not exist
Reply
#2

use SELECT to get the length, then can use the sort

select(' length(nome) as L')

orderBy('L asc')
Reply




Theme © iAndrew 2016 - Forum software by © MyBB