You said you cannot use `endswith` because `-A111` and `-111` will match, 
well what about just use endswith='-111' ?

On Thursday, January 3, 2019 at 3:17:43 PM UTC+2, 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/abf2c5d5-3525-41b2-99b7-86b759ca01a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to