Hello,

Can anyone please help with this.

Thanks,
Bijal

On Thursday, January 3, 2019 at 6:47:43 PM UTC+5:30, BIJAL MANIAR wrote:
>
>
> Hello,
>
> Consider below column in mysql table Employee. I need to write django orm 
> query for below mysql query.
> emp_number
> 4-DEF-A111
> 3-MNO-333
> 2-DEF-222
> 1-ABC-111
>
>
> Mysql query which splits by '-' and matches against last index.
> SELECT * from Employee WHERE substring_index(emp_number, '-', -1) = '111';
>
> I cannot write endswith on a column like below:
> Employee.objects.filter(emp_number__endswith='111').values('emp_number')
> This will return below 2 records:
> 4-DEF-A111
> 1-ABC-111
>
>  Any help would be appreciated. Thanks.
>
> -Bijal
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a3535912-e7a6-46ed-8770-cb55d183a633%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to