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