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
You can use a Func expression for this purpose[0]
Employee.objects.annotate(
emp_number_suffix=Func('emp_number', Value('-'), -1,
function='substring_index'),
).filter(
emp_number_suffix='111',
).values('emp_number')
Cheers,
Simon
[0]
https://docs.djangoproject.com/en/2.1/ref/models/ex
You can try with __contains queryset.
Regards,
Krishnasagar Subhedarpage
On Fri, 4 Jan 2019 at 15:34, BIJAL MANIAR wrote:
>
> 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,
>>
>> Co
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-DE
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) =
5 matches
Mail list logo