I have a item_group like 000
Now, I want to use Like Operator in frappe.db.sql
My query is
SELECT tabItem
.item_code as “Item Code”,tabItem
.name as “Item Name”
FROM tabItem
WHERE tabItem
.item_code
LIKE ‘000%%’ ORDER BY name desc limit 1;
I have a item_group like 000
Now, I want to use Like Operator in frappe.db.sql
My query is
SELECT tabItem
.item_code as “Item Code”,tabItem
.name as “Item Name”
FROM tabItem
WHERE tabItem
.item_code
LIKE ‘000%%’ ORDER BY name desc limit 1;
Example given in this link for like operator is also not working
https://docs.frappe.io/current/api/frappe.database
I have found the solution, it is working fine as shown in below example.
itcode = frappe.db.sql(“”“select item_code from tabItem
where item_code like %s order by created_on desc limit 1"”",“010%”)
The only issue I am facing is it is returning the value
((u’010-000100’,),)
whereas the actual value of item code is 010-000100
What is the solution for it.
Its nested tupple, access it as itcode[0][0].